douzhaochan6468 2015-05-05 14:33
浏览 48

PHP - 将视频上传到特定的Facebook相册

I'm facing some issues with PHP Facebook SDK and the upload of a video to a Facebook page.

I explain you: the video is uploaded correctly, but I want to insert it in a specific Facebook album. I think that the problem and also the solution is in these lines.

Moreover, the video is always uploaded in the Page Photos section and not in the Videos section.

How do I upload the video to a specific album or in the Videos section?

Thanks in advance for your help!

$response = (new FacebookRequest(
  $session, 'POST', '/{PAGE-ID}/videos', array(
    'source' => new CURLFile($pathtofile.$name, 'video/mp4'),
    'title' => basename($name, ".mp4")      

EDIT

I edited my code in this way, using the cURL library, but the problem is still the same: the video is uploaded into the Photo section.

Is there a way to upload it into the Video album?

$attachment = array(
        'access_token'=> 'access_token',
        'title' => 'Video Title',
        'source'=> new CURLFile("$pathtofile", 'video/mp4'));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph-video.facebook.com/v2.2/pageid/videos');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //to suppress the curl output 
$result = curl_exec($ch);
print_r($result);
curl_close ($ch);
  • 写回答

1条回答 默认 最新

  • douliu7929 2015-05-12 21:46
    关注

    Doing a Graph API Call like this:

    curl \
    -F "title=Video Title" \
    -F "access_token=page_access_token_with_publish_actions_permission" \
    -F "source=@/path/to/my_video.MOV" \
    "https://graph-video.facebook.com/v2.2/page_id/videos"
    

    Worked as expected. Just to mess around with it, instead of publishing to graph-video.facebook.com, I tried uploading to graph.facebook.com. Both videos I uploaded were sent to my videos album.

    My Page's videos

    I would try doing the same CURL call, with the video you're trying to upload and see if it works that way.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用