使用Facebook视频ID获取Facebook视频缩略图大小 - PHP

时间:2016-07-16 11:43:58

标签: php facebook facebook-graph-api video

您好我已经检查了很多有关此问题的Stackoverflow问题。以下是我看过的问题清单:

  1. Get Facebook video thumbnail image URLs?
  2. How to get Facebook video thumbnail from its video id?
  3. How to get big facebook video thumbnail
  4. How to get facebook video thumbnail from a given video ID using php
  5. Get large facebook video thumbnail using graph
  6. 但我从哪里得到答案。

    我用过这个:https://graph.facebook.com/VIDEO_ID/picture,它有效,但给了我很小的缩略图。

    如果你有任何办法,请帮助我。提前致谢

2 个答案:

答案 0 :(得分:1)

我发现如何使用缩略图高解决方案,并成功获得缩略图高解决方案。您可以使用以下代码:

$video_id= Input::get('id_video');
$config = [
    'app_id' => \Config::get('setting.APP_ID'),
    'app_secret' => \Config::get('setting.SECRET_ID'),
    'default_graph_version' => 'v2.7',
];

$fb = new Facebook($config);

$accessToken = Input::get('access_token');


$url = "https://graph.facebook.com/".$video_id."?fields=description,thumbnails&access_token=".$accessToken;
//Make the API call
$result = file_get_contents($url);
//Decode the JSON result.
$decoded = json_decode($result, true);
//Dump it out onto the page so that we can take a look at the structure of the data.
var_dump($decoded);

$ accessToken我从Graph explorer工具获得,或者你编写函数登录facebook你可以获得access_token。 https://developers.facebook.com/docs/php/howto/example_facebook_login

我希望能帮到你!

答案 1 :(得分:0)

与你相同,我使用Graph explorer可以获得缩略图视频,但我无法从“https://graph.facebook.com/VIDEO_ID/picture”获得缩略图。您可以关注

/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/{video-id}'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */