2017-01-17 22 views
1

私はこの図鑑アカウントhttps://www.instagram.com/nasa/ .....の画像を私のウェブサイトに表示しようとしています。他のアカウントから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を試してみるともう動作しません。私はそれは2つの理由の一つかもしれない

答えて

1

をしないのですかを理解しようとすると:

  1. サンドボックスモードである場合は、あなただけのAPIレスポンスであなたとあなたのサンドボックスのユーザーの投稿を取得します。ライブモードに移行すると、すべてのデータがAPIレスポンスになります。サンドボックスモードの詳細情報:https://www.instagram.com/developer/sandbox/

  2. あなたはライブモードになっていると、他のユーザーからのデータが表示されない場合は、あなたがのOAuth2中public_contentスコープを使用して認証していない可能性があり。ログイン許可の詳細:https://www.instagram.com/developer/authorization/

関連する問題