[英]How to receive RealTime Instagram update using python-instagram?
I just wanted to know how to receive RealTime Update
the update from python-instagram
我只是想知道如何从
python-instagram
接收RealTime Update
更新
It's actually a Flask application and hosted in Google Cloud VM. 它实际上是Flask应用程序,托管在Google Cloud VM中。 So far so good.
到现在为止还挺好。 I can subscribe to the particular
tag
or user
. 我可以订阅特定的
tag
或user
。 And I think instagram post the update to my server. 而且我认为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)"
So I guess using the reactor is best way to receive and I did something like this .... 所以我想使用电抗器是最好的接收方式,我做了这样的事情....
""" 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 handling .... 挂钩网址处理....
@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)
But I don't know is this the right way... I got blind what will come from process_tag_update(update)
because ... 但是我不知道这是正确的方法...我不知道
process_tag_update(update)
会带来什么,因为...
So Is anybody experiencing similar issue.. ? 那么有人遇到类似的问题吗? How to overcome this.?
如何克服这个? And also if you have any ideas to achieve please let me know..
另外,如果您有任何想法要实现,请告诉我。
The problem is 301
redirect. 问题是
301
重定向。 You have to make sure your real time callback URL ends with /
您必须确保您的实时回调URL以
/
结尾
Ex:- /hook/instagram/
例如:-
/hook/instagram/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.