I have been using Instagram Subscription API to subscribe to Instagram real time updates. I have successfully subscribed to multiple subscriptions on Instagram. But now it is giving me the following error when I try to subscribe:
meta": {
"error_type": "OAuthAccessTokenException",
"code": 400,
"error_message": "The access_token provided is invalid."
}
Earlier it never used to ask for access token for subscription API. Can anyone please explain Instagram API.
Too old but I hope will be helpful to some people.
Creating a subscription is 4 step process:-
Step One: Direct your user to our authorization URL:-
GET request :-
https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code
Step Two: Receive the redirect from Instagram
As a response of step 1, Instagram will provide you a http://your-redirect-uri?code=CODE on success, which you will use in step three. Note: CODE is not access token, you will use CODE to get access token.
Step Three: Request the access_token:-
POST CURL Request :-
on success DEMO Data
Step Four: Creating a Subscription
Step Four has some sub steps. i) POST curl request to Instagram API
ii) On success Instagram will provide
on callback page eg:
callback.php
iii) If the Instagram API will get
$_GET['hub_challenge']
that is15f7d1a91c1f40f8a748fd134752feb3
here it will reply for our post request to create a subscription withsomething like
iii) If success you can list out the subscription with a GET request may be directly from your browser. GET Request:-
https://api.instagram.com/v1/subscriptions?client_secret=CLIENT-SECRET&client_id=CLIENT-ID
now when ever the authenticated users will post the callback page will get a GET request from Instagram api with some JSON data containing instagram user_id that you will get as object_id and media_id that is the post id. You can catch that and use that with the below code, yes you can use better code than me , that is GREAT.