通过PHP API在fanpage上上传视频 [英] Upload video on fanpage via PHP API

查看:116
本文介绍了通过PHP API在fanpage上上传视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


{错误:{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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆