通过PHP API在fanpage上上传视频 [英] Upload video on fanpage via PHP API
问题描述
{错误:{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有效,并作为应用程序登录,在 $数据
我已经尝试只设置'file'或'source',但效果是一样的。
p>您最好使用Facebook PHP SDK,但可能会像删除文件参数并将@添加到源路径中一样简单。以下是SDK的一个工作示例(假设您已经请求了相应的FB权限):
$这 - > facebook-> setFileUploadSupport(真);
$ upload = $ this-> facebook-> api('/ me / videos','POST',array(
'source'=>'@'.$文件,
'title'=> $ title,
'description'=> $ description
));
I have a little problem with my FB application. It's about that I always get error:
{"error":{"message":"(#353) Missing video file","type":"OAuthException","code":353}}
with this code:
$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);
File exist, access_token is valid and is logged as a app, In $data
I've tried set only 'file' or 'source' but effects was the same.
You are best off using the Facebook PHP SDK for this, but it might be as simple as removing your file param and adding "@" to your source path. Here is a working example with the SDK (assuming you have asked for the appropriate FB permissions):
$this->facebook->setFileUploadSupport(true);
$upload = $this->facebook->api('/me/videos', 'POST', array(
'source' => '@'.$file,
'title' => $title,
'description' => $description
));
这篇关于通过PHP API在fanpage上上传视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!