0

我的 FB 应用程序有一点问题。这是关于我总是得到错误:

{"error":{"message":"(#353) 缺少视频文件","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我尝试仅设置“文件”或“源”但效果相同。

4

1 回答 1

0

为此,您最好使用 Facebook PHP SDK,但它可能就像删除文件参数并将“@”添加到源路径一样简单。这是一个使用 SDK 的工作示例(假设您已请求适当的 FB 权限):

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

$upload = $this->facebook->api('/me/videos', 'POST', array(
    'source' => '@'.$file,
    'title' => $title,
    'description' => $description
));
于 2013-03-27T14:48:28.047 回答