Search code examples
javaweb-applicationsinstagram-api

Instagram API - How to Subscribe to a specific User


I am trying to use the Instagram-API to subscribe to a user so that when that user posts anything on Instagram, then my app will receive a POST. I have set up the app in the sandbox, defined the callback URIs, added my user to the Sandbox, then called the following url to register a subscription;

https://api.instagram.com/v1/subscriptions?client_id=MY_CLIENT_ID&client_secret=MY_CLIENT_SECRET&object=user&user_id=jonlees1234&aspect=media&verify_token=1234567890&callback_url=https://instagram.pulselive.com/SubscriptionCallback

The part of that URL that I am unclear about is the following;

&object=user&user_id=jonlees1234&aspect=media

I have a GET and POST method on my Callback Url so that when the SubscriptionValidation GET is called the hub.challenge is echoed. I have tested this and it works. However, the response I get from the above URL is as follows;

{"meta":{"code":200},"data":[]}

This indicates that all is working, but that there are no subscriptions when I run the list of subscriptions api call.

What could I be missing?


Solution

  • Ok, I finally I found the answer.

    https://api.instagram.com/v1/subscriptions?client_id=MY_CLIENT_ID&client_secret=MY_CLIENT_SECRET&object=user&id=3111490094&aspect=media&verify_token=THE_USERS_ACCESS_TOKEN&callback_url=http://instagram.pulselive.com/SubscriptionCallback

    The KEY issue was that I was using the username and I SHOULD have been using the user id, as follows;

    &object=user&id=1234567890&aspect=media

    All working now.