Instagram Invalid Response Error - 400

匿名 (未验证) 提交于 2019-12-03 02:41:02

问题:

I have the following code.

    params = {'client_id':settings.SOCIAL_AUTH_INSTAGRAM_KEY,               'client_secret':settings.SOCIAL_AUTH_INSTAGRAM_SECRET,               'aspect':'media',               'object':'tag',               'object_id':instance.hashtag,               'callback_url':                   'http://subdomain.domain.net:8000/campaigns/hook'}     response = requests.post('https://api.instagram.com/v1/subscriptions',                              data=params) 

And I get response

'{"meta":{"error_type":"APISubscriptionError","code":400,"error_message":"Invalid response"}}'

My domain is reachable from outside. Any ideas?

回答1:

This was because Instagram sends a GET request to my callback_url and wants me to response with hub.challenge parameter like below

    if self.request.GET:             response = request.GET.get('hub.challenge')             return HttpResponse(response) 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!