Mit*_*thc 3 facebook-graph-api facebook-php-sdk instagram-api
I'm using the Instagram Graph API in a business account, and almost everything works just fine. I have created a WordPress port of the Facebook SDK, and the function that retrieves the media items looks like this (part of a class, the $fb object is already authenticated using the default_access_token in the class constructor):
public function get_media( $business_account_id = '', $limit = 15 ) {
$limit = absint( $limit );
try {
$response = $this->fb->get( "/{$business_account_id}?fields=media.limit({$limit}){media_url,caption,thumbnail_url,permalink}" );
return $response->getDecodedBody();
} catch ( \Facebook\Exceptions\FacebookResponseException $e ) {
return $e->getMessage();
} catch ( \Facebook\Exceptions\FacebookSDKException $e ) {
return $e->getMessage();
}
}
Run Code Online (Sandbox Code Playgroud)
The fields I'm requesting, as you can see, are: media_url, caption, thumbnail_url and permalink. The API responds with all the fields except for thumbnail_url:
array(2) {
["media"]=>
array(2) {
["data"]=>
array(15) {
[0]=>
array(4) {
["media_url"]=>
string(91) "https://scontent.xx.fbcdn.net/..."
["caption"]=>
string(356) "[...]"
["permalink"]=>
string(40) "https://www.instagram.com/p/.../"
["id"]=>
string(17) "..."
}
...
}
["paging"]=>
array(2) {
["cursors"]=>
array(2) {
["before"]=>
string(123) "..."
["after"]=>
string(122) "..."
}
["next"]=>
string(438) "https://graph.facebook.com/v2.10/..."
}
}
["id"]=>
string(17) "..."
}
Run Code Online (Sandbox Code Playgroud)
I get the same response using the Graph API Explorer, which makes me think is something related to my app, maybe permissions (currently manage_pages and instagram_basic), a special setting or a bug (I don't think so, but just in case...).
What am I missing?
看起来thumbnail_url只能在视频IG Media对象上使用。我的解决方案是使用PHP处理图像以生成媒体对象的调整大小的版本并将其缓存,因此我不必在每次请求时都重新生成它们。
| 归档时间: |
|
| 查看次数: |
1703 次 |
| 最近记录: |