php 如何使用 Instagram API 获取图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40105795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get images using Instagram API
提问by adeel ali
How to get users images from Instagram API?
如何从Instagram API获取用户图片?
access_token=4049241557.1677ed0.5324ad17d9314645b528ad112da8d56e
access_token=4049241557.1677ed0.5324ad17d9314645b528ad112da8d56e
But no success, it's giving me only user info. How can I get images using Instagram API?
但没有成功,它只给我用户信息。如何使用 Instagram API 获取图像?
回答by krisrak
Use this API:
使用这个 API:
https://api.instagram.com/v1/users/self/media/recent?access_token={access-token}
This will get your photos,(but it looks like from the access_token
you have posted, that user does not have any photos posted, so it will return empty array)
这将获取您的照片,(但从access_token
您发布的内容来看,该用户没有发布任何照片,因此它将返回空数组)
Use this to get other user's photo:
使用它来获取其他用户的照片:
https://api.instagram.com/v1/users/{user-id}/media/recent?access_token={access-token}
you should have authenticated with public_content
scope and if you are in sandbox mode, only sandbox users can be accessed until your app is reviewed and live
您应该已通过public_content
范围进行身份验证,如果您处于沙箱模式,则只有沙箱用户才能访问您的应用程序,直到您的应用程序被审核并上线
回答by Williaan Lopes
You could use this library Cosenary.
你可以使用这个库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();
Read the documentation for more information.
阅读文档以获取更多信息。
Hope this helps.
希望这可以帮助。