Instagram Real-Time API Callback URL Escaping [duplicate]

北慕城南 提交于 2019-12-04 14:39:03

The callback url is fine. The extra \s you see are due to the way JSON encodes the / character. Check out the escape rules here: http://www.json.org/

The real problem is that Instagram's real-time subscriptions API seems to be having issues for the last couple days. See @DanShev's comment for the links.

In the mean time, I have a system in place to periodically look through my users' photos for photos that are of interest to me. My code (in Python) looks something like this:

from instagram import client
users = InstagramUser.objects.all()
for user in users:
    api = client.InstagramAPI(access_token=user.access_token)
    user_media, paginate_url = api.user_recent_media(user_id=user.instagram_user_id)
    for media in user_media:
        # Check if this is a media we've already gotten via subscription update
        # Do somethign with the media

I've been having the same issue over the last few days. As a last ditch effort, I tried clearing all my subscriptions using the API, in case there were orphans running through the system. YMMV, but this ended up solving my "Cannot reach callback_url" problems.

The final section of the Realtime Photo Updates API docs has the details. To quickly test from the command line, give their curl example a go:

curl -X DELETE 'https://api.instagram.com/v1/subscriptions?client_secret=CLIENT-SECRET&object=all&client_id=CLIENT-ID'

If this ends up working for you, I'd recommend updating your app code to delete any existing subscriptions for a given client_id before starting a new subscription. Of course, this is only viable if you limit yourself to creating one subscription per set of credentials. If you're creating more than one subscription, you'll need to keep track of the queries that make up your active subscriptions and delete those that already exist before recreating.

This was actually a bug on Instagram's end. They fixed it, and it should be working now.

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