gpt4 book ai didi

python - 如何使用 python-instagram 接收实时 Instagram 更新?

转载 作者:行者123 更新时间:2023-12-01 04:25:32 25 4
gpt4 key购买 nike

我只是想知道如何接收RealTime Update来自<a href="https://github.com/Instagram/python-instagram" rel="noreferrer noopener nofollow">python-instagram</a>的更新

它实际上是一个 Flask 应用程序,托管在 Google Cloud VM 中。到目前为止,一切都很好。我可以订阅特定的taguser 。我认为 Instagram 将更新发布到我的服务器。

173.252.105.114 - - [19/Oct/2015:01:40:52 -0400] "POST /hook/instagram HTTP/1.1" 301 517 "-" "Python-httplib2/0.8 (gzip)"
173.252.108.115 - - [19/Oct/2015:01:40:53 -0400] "POST /hook/instagram HTTP/1.1" 301 517 "-" "Python-httplib2/0.8 (gzip)"
173.252.108.119 - - [19/Oct/2015:01:41:31 -0400] "POST /hook/instagram HTTP/1.1" 301 517 "-" "Python-httplib2/0.8 (gzip)"
173.252.113.116 - - [19/Oct/2015:01:41:41 -0400] "POST /hook/instagram HTTP/1.1" 301 517 "-" "Python-httplib2/0.8 (gzip)"

所以我想使用 react 堆是最好的接收方式,我做了这样的事情......

""" Hook for real time update """
def process_tag_update(update):
new = RealUpdate(update['subscription_id'], updata['object_id'], update['object'])
db.session.add(new)
db.session.commit()
print 'Received a push: '

reactor = subscriptions.SubscriptionsReactor()
reactor.register_callback(subscriptions.SubscriptionType.TAG, process_tag_update)

Hook url 处理 ....

@app.route('/hook/instagram/',methods=['GET', 'POST'])
def hook_instagram():
if request.method == 'POST':
# POST event is used to for the events notifications
x_hub_signature = request.headers.get('X-Hub-Signature')
raw_response = request.data
try:
reactor.process(CLIENT_SECRET, raw_response, x_hub_signature)
except subscriptions.SubscriptionVerifyError:
print 'Signature mismatch'
return 'done'
else:
hub_challenge = request.args.get('hub.challenge')
return '{}'.format(hub_challenge)

但我不知道这是正确的方法...我盲目了 process_tag_update(update) 会产生什么因为...

  1. 我无法打印
  2. 我无法调试

那么有人遇到类似的问题吗..?如何克服这个问题?如果您有任何想要实现的想法,请告诉我..

最佳答案

问题是 301 重定向。您必须确保您的实时回调 URL 以 /

结尾

例如:- /hook/instagram/

关于python - 如何使用 python-instagram 接收实时 Instagram 更新?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33207412/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com