2013-03-27 117 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