使用PHP通过Graph API将视频发布到Facebook页面

时间:2017-07-28 11:27:49

标签: php facebook facebook-graph-api

我需要使用php中的API在我的脸书页面上发布视频,但我收到了以下错误:

No permission to publish the video

以下是我的代码:

$fb = new Facebook\Facebook([
  'app_id' => '184937xxxxxxxxx',
  'app_secret' => '63ba95384b898fxxxxxxxx',
  'default_graph_version' => 'v2.10',
]);

$data = [
  'title' => 'My Foo Video',
  'description' => 'This video is full of foo and bar action.',
  'source' => $fb->videoToUpload('test.mp4'),
];
$pageAccessToken ='xxxxxxxxxxxxxxxxxxxxxx';
try {
  //825870214256735 is page id
  $response = $fb->post('/825870214256735/videos', $data, $pageAccessToken);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  // When Graph returns an error
  echo 'Graph returned an error: ' . $e->getMessage();
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  // When validation fails or other local issues
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
}

0 个答案:

没有答案