def subscribe_to_objects_by_tag(self, search_terms): def process_tag_update(update): print update reactor = subscriptions.SubscriptionsReactor() reactor.register_callback(subscriptions.SubscriptionType.TAG, process_tag_update) self.api.create_subscription(object='tag', object_id=search_terms, aspect='media', callback_url='http://localhost:8211/')
def on_realtime_callback(): reactor = subscriptions.SubscriptionsReactor() reactor.register_callback(subscriptions.SubscriptionType.TAG, process_tag_update) mode = request.GET.get("hub.mode") challenge = request.GET.get("hub.challenge") verify_token = request.GET.get("hub.verify_token") if challenge: return challenge else: x_hub_signature = request.header.get('X-Hub-Signature') raw_response = request.body.read() try: reactor.process(CONFIG['client_secret'], raw_response, x_hub_signature) except subscriptions.SubscriptionVerifyError: print("Signature mismatch")
def __init__(self, tags, **settings): routes = [ (r"^/$", IndexHandler), # (r"^/instagram/subscriptions", SubscriptionsHandler), (r"^/posts", PostsHandler), (r"^/instagram/subscriptions/([a-z0-9_-]+)/([a-z0-9_-]+)", SubscriptionsHandler), ] settings = dict( template_path=os.path.join(os.path.dirname(__file__), "templates"), static_path=os.path.join(os.path.dirname(__file__), "static"), debug=config.DEBUG, ) tornado.web.Application.__init__(self, routes, **settings) self.reactor = subscriptions.SubscriptionsReactor() self.reactor.register_callback(subscriptions.SubscriptionType.TAG, self.process_update) self.tags = tags
def parse_instagram(): from instagram import client, subscriptions mode = request.values.get('hub.mode') challenge = request.values.get('hub.challenge') verify_token = request.values.get('hub.verify_token') if challenge: return Response(challenge) else: reactor = subscriptions.SubscriptionsReactor() reactor.register_callback(subscriptions.SubscriptionType.USER, parse_instagram_update) x_hub_signature = request.headers.get('X-Hub-Signature') raw_response = request.data try: reactor.process(INSTAGRAM_SECRET, raw_response, x_hub_signature) except subscriptions.SubscriptionVerifyError: logging.error('Instagram signature mismatch') return Response('Parsed instagram')
'redirect_uri': 'http://*****:*****@hook('before_request') def setup_request(): request.session = request.environ['beaker.session'] def process_tag_update(update): print(update) reactor = subscriptions.SubscriptionsReactor() reactor.register_callback(subscriptions.SubscriptionType.TAG, process_tag_update) @route('/') def home(): try: url = unauthenticated_api.get_authorize_url( scope=["likes", "comments"]) return '<a href="%s">Connect with Instagram</a>' % url except Exception as e: print(e) def get_nav():