L
L
lexstile2018-02-07 02:09:00
PHP
lexstile, 2018-02-07 02:09:00

Why is there an error in getting a photo from the Instagram feed?

The access_token provided is invalid.
Application in sandbox mode. I get personal information for the current token (profile photo, id, name, etc.)

/*****************************************************************/
$token = $query['access_token'];
$user_id = $query['user_id'];

$instagram_cnct = curl_init();
curl_setopt( $instagram_cnct, CURLOPT_URL, "https://api.instagram.com/v1/users/" . $user_id . "/media/recent?access_token=" . $token );
curl_setopt( $instagram_cnct, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $instagram_cnct, CURLOPT_TIMEOUT, 15 );
$media = json_decode( curl_exec( $instagram_cnct ) );
curl_close( $instagram_cnct );
 print_r($media);

$limit = 4;
$size = 200;

foreach(array_slice($media->data, 0, $limit) as $data) {
  echo '<a href="' . $data->link . '" target="_blank">';
  echo '<img src="'. $data->images->low_resolution->url . '" height="'.$size.'" width="'.$size.'"/>';
  echo '</a>';
}
/*****************************************************************/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-02-10
@dimonchik2013

decompose

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question