2013-03-27 112 views
0

我的FB应用程序有点问题。这是关于我总是得到错误:通过PHP API在fanpage上传视频

{"error":{"message":"(#353) Missing video file","type":"OAuthException","code":353}}

与此代码:

  $post_url  = "https://graph-video.facebook.com/xxx/videos?" 
        . "title=" . $video_title . "&description=" . $video_desc 
        . "&access_token=" . $access_token; 
      $ch = curl_init(); 
      $data = array(
       'source' => 'http://x/upload/' . $name . '.' . $type, 
       'file' => './upload/' . $name . '.' . $type, 
       'type' => 'avi', 
      ); 
      curl_setopt($ch, CURLOPT_URL, $post_url); 
      curl_setopt($ch, CURLOPT_POST, 1); 
      curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 
      $response = curl_exec($ch); 
      if (!$response) 
      { 
       print_r(Debug::vars(array(curl_error($ch), curl_errno($ch)))); 
      } 
      curl_close($ch); 

文件存在的access_token是有效的,被记录为一个应用程序,在$data我已经试过只设置“文件”或'来源',但效果是一样的。

回答

0

你最好使用Facebook PHP SDK来做这件事,但它可能就像删除文件参数并将“@”添加到源路径一样简单。下面是使用SDK的工作示例(假设你已要求相应的权限FB):

$this->facebook->setFileUploadSupport(true); 

$upload = $this->facebook->api('/me/videos', 'POST', array(
    'source' => '@'.$file, 
    'title' => $title, 
    'description' => $description 
)); 
+0

我很愚蠢;)寻求帮助THX – 2013-03-27 15:23:22