【问题标题】:How do I return the Instagram Realtime subscription challenge?如何返回 Instagram 实时订阅挑战?
【发布时间】:2012-11-14 21:47:06
【问题描述】:

我正在尝试订阅标签。似乎使用hub.challenge 和hub.mode 正确调用了回调URL,我想出了如何使用self.request.get('hub.challenge') 访问挑战。我以为我只是应该回应挑战,但这似乎不起作用,因为我在 GAE 日志中收到以下错误:

InstagramAPIError: (400) APISubscriptionError-Challenge verification failed. Sent "647bf6dbed31465093ee970577ce1b72", received "
647bf6dbed31465093ee970577ce1b72
".

这是完整的处理程序:

class InstagramHandler(BaseHandler):
    def get(self):
        def process_tag_update(update):
            update = update

        mode         = self.request.get('hub.mode')
        challenge    = self.request.get('hub.challenge')
        verify_token = self.request.get('hub.verify_token')
        if challenge:
            template_values = {'challenge':challenge}
            path = os.path.join(os.path.dirname(__file__), '../templates/instagram.html')
            html = template.render(path, template_values)
            self.response.out.write(html)
        else:
            reactor = subscriptions.SubscriptionsReactor()
            reactor.register_callback(subscriptions.SubscriptionType.TAG, process_tag_update)

            x_hub_signature = self.request.headers.get('X-Hub-Signature')
            raw_response    = self.request.data
            try:
                reactor.process('INSTAGRAM_SECRET', raw_response, x_hub_signature)
            except subscriptions.SubscriptionVerifyError:
                logging.error('Instagram signature mismatch')

【问题讨论】:

    标签: python google-app-engine instagram


    【解决方案1】:

    所以将它作为字符串返回是可行的。我应该更仔细地注意错误消息,但是 Python IRC 上的一位乐于助人的人指出了消息中的额外换行符。一旦我将模板文件放在一行上,它似乎就可以工作了。我现在可以通过 Instagram 的列表订阅 URL 确认我的应用已获得授权。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-21
      • 1970-01-01
      • 2016-12-02
      相关资源
      最近更新 更多