@lexstile

Как вернуть json c данными пользователя инстаграм?

Ребят, как мне отправить запрос, чтобы вернулся json?
https://www.instagram.com/developer/authentication/

Step Three: Request the access_token

Now you need to exchange the code you have received in the previous step for an access token. In order to make this exchange, you simply have to POST this code, along with some app identification parameters, to our access_token endpoint. These are the required parameters:

client_id: your client id
client_secret: your client secret
grant_type: authorization_code is currently the only supported value
redirect_uri: the redirect_uri you used in the authorization request. Note: this has to be the same value as in the authorization request.
code: the exact code you received during the authorization step.
This is a sample request:
curl -F 'client_id=CLIENT_ID' \
    -F 'client_secret=CLIENT_SECRET' \
    -F 'grant_type=authorization_code' \
    -F 'redirect_uri=AUTHORIZATION_REDIRECT_URI' \
    -F 'code=CODE' \
    https://api.instagram.com/oauth/access_token

If successful, this call will return a neatly packaged OAuth Token that you can use to make authenticated calls to the API. We also include the user who just authenticated for your convenience:
{
    "access_token": "fb2e77d.47a0479900504cb3ab4a1f626d174d2d",
    "user": {
        "id": "1574083",
        "username": "snoopdogg",
        "full_name": "Snoop Dogg",
        "profile_picture": "..."
    }
}


Пробую так, но ничего не происходит:
if(isset($_GET['code'])):
$instagram = curl_init();
curl_setopt($instagram, CURLOPT_URL, "https://api.instagram.com/oauth/access_token?client_id=".CLIENT_ID."&client_secret=".CLIENT_SECRET."&grant_type=authorization_code&redirect_uri=".REDIRECT_URI."&code=".$_GET['code']);
curl_setopt($instagramt, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($instagram, CURLOPT_TIMEOUT, 15 );
$media = json_decode(curl_exec($instagram));
curl_close($instagram);
print_r($media);
endif;
  • Вопрос задан
  • 1398 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы