简体   繁体   中英

not able to get instagram images from other accounts

I am trying to display images from this instagram account https://www.instagram.com/nasa/ .....into my website. I can display content from my own instagram account just fine by doing

<?php

    $instagram_access_token = 'instagram access token';
    $instagram_account_id = 'instagram account id'; // works fine with my account id

    $call = file_get_contents('https://api.instagram.com/v1/users/'.$instagram_account_id.'/media/recent/?access_token='.$instagram_access_token);

    $obj = json_decode($call)->data;
    for( $i = 0; $i < sizeof($obj); $i++){
        echo "<div class='instagram-image-class'>";
        $img = $obj[$i]->images->standard_resolution->url;
        echo '<img alt="'.$obj[$i]->caption->text.'" src="' . $img . '"/>';
        if($obj[$i]->caption){
            echo '<div class="instagram-image-caption">' .$obj[$i]->caption->text. '</div>';
        }
        echo "</div>";
    };

?>

But the moment I try another account ID it doesn't work any more. Trying to understand what am I missing

It could be one of 2 reasons:

  1. If you are in sandbox mode, you will only get your and your sandbox user's posts in API response. Once you go live mode, all data will be API response. More info on sandbox mode: https://www.instagram.com/developer/sandbox/

  2. If you are in live mode and not seeing data from other users, then you may not have authenticated using public_content scope during oauth2. More info on login permissions: https://www.instagram.com/developer/authorization/

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM