【问题标题】:php publish video to facebook wallphp将视频发布到facebook墙
【发布时间】:2015-01-05 15:16:57
【问题描述】:

我正在尝试创建一个将视频上传和发布到用户墙上的应用。 在 api 文档之后没有发布示例

https://developers.facebook.com/…/reference/v2.2/user/videos

我在这里查找了类似的问题,但它们都是旧的,指的是 fb api。

当我使用 curl 时,API 返回一条我应该使用 curl 的消息 它返回 false。

有没有发布视频的php例子?

我的代码示例:

$url = 'https://graph-video.facebook.com/me/videos';
$cfile = new CURLFile('test.mp4','video/mp4','video');

$post_params = array(
            'title' => "myTitle",
            'name' => "blahblah",
            'source' => $cfile,
            'access_token' => $token    
       );
$ch = curl_init();

    //set the url, number of POST vars, POST data 
   curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));

   curl_setopt($ch,CURLOPT_URL,$url);
   curl_setopt($ch,CURLOPT_POST,1);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
   //execute post 
   $result = curl_exec($ch);

谢谢!

【问题讨论】:

    标签: php curl facebook-php-sdk


    【解决方案1】:

    我使用 FB API 和 CURLFile 找到了答案,希望对其他人有所帮助

       $url = 'https://graph-video.facebook.com/me/videos';
    
       $cfile = new CURLFile(realpath('test.flv'),'video/x-flv');
    
       $movie_data = array('file' => $cfile);
    
       $post_params = array(
          'title' => "ffff",
           'name' => "tablished businesses”",
           'source' => $cfile,
           'access_token' => $token    
       );
    
       $request = new FacebookRequest(
                  $session,
                  'POST',
                  '/me/videos',
                  $post_params
                );
    
    
    
       $response = $request->execute();
    

    $response 包含视频的 ID。

    享受

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-31
      • 1970-01-01
      • 1970-01-01
      • 2012-06-23
      • 1970-01-01
      相关资源
      最近更新 更多