2017-01-17 43 views
1

我想從此instagram帳戶https://www.instagram.com/nasa/ .....中顯示圖像到我的網站。我可以通過自己的Instagram帳戶顯示內容,只需做好無法從其他帳戶獲取Instagram圖片

<?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>"; 
    }; 

?> 

但是,當我嘗試其他帳戶ID時,它不再工作。試圖瞭解我缺少

回答

1

這可能是兩個原因之一:

  1. 如果你在沙盒模式,你只會得到你和你的沙箱用戶帖子的API響應。一旦你進入直播模式,所有的數據將是API響應。沙盒模式更多信息:https://www.instagram.com/developer/sandbox/

  2. 如果你是在現場模式,而不是從其他用戶看到的數據,那麼你可能沒有使用的oauth2期間public_content範圍認證。有關登錄權限的更多信息:https://www.instagram.com/developer/authorization/

相關問題