2016-10-18 119 views
0

如何從Instagram API獲取用戶圖像?如何使用Instagram API獲取圖像

=的access_token 4049241557.1677ed0.5324ad17d9314645b528ad112da8d56e

但沒有成功,它給我的只有用戶信息。 如何使用Instagram API獲取圖像?

+0

檢查此鏈接:https://code.tutsplus.com/tutorials/introduction-to-the-instagram-api--cms-23608 – fernando

回答

2

使用此API:

https://api.instagram.com/v1/users/self/media/recent?access_token={access-token} 

這將讓你的照片,(但它看起來像從access_token您已發佈,該用戶沒有任何的照片貼出來,所以它會返回空數組)

使用此得到其他用戶的照片:

https://api.instagram.com/v1/users/{user-id}/media/recent?access_token={access-token} 

你應該有public_content範圍,如果你是在沙盒模式,只有SAN認證dbox用戶可以訪問,直到您的應用程序進行審查和生活

+0

嗨@krisrak如何批准public_content和關係權限。我提交了我的應用,但他們拒絕了這兩個權限 – abhi

+0

你的應用做什麼? – krisrak

+0

發佈者創建一個門併爲其他用戶添加下載路徑,他還添加了一個instagram用戶名。 如果用戶想要下載該曲目,那麼他必須遵循該instagram用戶。 我爲它使用PHP api。 – abhi

0

您可以使用此庫Cosenary

use MetzWeb\Instagram\Instagram; 

$instagram = new Instagram(array(
    'apiKey'  => 'YOUR_APP_KEY', 
    'apiSecret' => 'YOUR_APP_SECRET', 
    'apiCallback' => 'YOUR_APP_CALLBACK' 
)); 

// grab OAuth callback code 
$code = $_GET['code']; 
// or maybe $code = $request->code; // if you are using Laravel 
$data = $instagram->getOAuthToken($code); 

// set user access token 
$instagram->setAccessToken($data); 

// and 
$pictures = $instagram->getUserMedia(); 

閱讀文檔以獲取更多信息。

希望這會有所幫助。

相關問題