问题
I'm using Instagram's Real-Time API to receive live updates when users post a picture. This was all set up and working perfectly. Randomly today it has decided not to work.
Debugging steps already taken:
- Client / Application is registered with Instagram
Verify at least one user is already subscribed... I know this because when I verify the list I get this response (example.com substituted for actual domain).
{ "meta": {"code":200}, "data: [{ "object":"user", "object_id":null, "aspect":"media", "callback_url":"
http:\/\/example.com\/common\/instagram\/subscriptions
", "type":"subscription", "id":"4270301" }] }- Create new application and start from scratch (same results)
Clearly, something weird is happening with the callback_url though. You can see the sample response does not have the backslashes. I also get the same situation when trying to subscribe a new user via curl, formatted exactly like Instagram's example. Instagram is trying to use "http:\/\/example.com\/common\/instagram\/subscriptions
" and returns "Unable to reach callback URL".
I have read a bunch of other questions regarding the API, but no one seems to report anything like this. There have now been multiple other reports of similar issues (see Instagram API - Unable to reach callback URL, Node.js Instagram APISubscriptionError, etc.). At this point my only guess is that the problem is on Instagram's side, but hopefully me overlooking something or making a silly mistake.
Endless thanks to whoever can point me in the right direction. Cheers.

回答1:
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
回答2:
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.
回答3:
This was actually a bug on Instagram's end. They fixed it, and it should be working now.
来源:https://stackoverflow.com/questions/22997470/instagram-real-time-api-callback-url-escaping