I am trying to make a website that displays my friend's instagram follower count and recent images. I finally think I have figured out how to do it but I am running into an error. Every time I run my php file I get
stdClass Object ( [meta] => stdClass Object ( [error_type] => APINotFoundError [code] => 400 [error_message] => invalid media id ) )
The code I am running is:
<?php
function extractData(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
"https://api.instagram.com/v1/media/shortcode/D?access_token=*");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$activate= extractData();
print_r(json_decode($activate));
?>
I have a valid access key I just took it out for security reasons.
I think your endpoint URL is incorrect. It's not specifying any data, when it should look at your buddy's account. See: https://www.instagram.com/developer/endpoints/users/#get_users for the return data as well.
Change the URL to match the correct user:
"https://api.instagram.com/v1/users/{user-id}/?access_token=*");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.