将视频上传到旧的Facebook REST API [英] Uploading video to old Facebook REST API

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

问题描述

如果我尝试使用 https://api-video.facebook,我有很多上传视频的问题。



com 我得到一个cURL主机找不到错误,如果我使用 http://api-video.facebook.com 我收到一条消息使用 https://api-video.facebook.com



如果我尝试使用 https://api.facebook.com/restserver.php?method=video.upload 我收到一个101错误代码 -

 < error_msg>无效的API密钥< / error_msg> 

但API密钥适用于用户的其他一切,状态,评论,喜欢,fql? / p>

我要发送什么:

  access_token = XXXX 
api_key = XXXX
call_id = 1279204007.6003
description =描述+的+这个%3F
格式= JSON
标题=标题%2C + a +标题
v = 2.0
sig = XXX

我在发表在 FB开发者论坛将会话密钥分解为|给你一个正确的会话密钥?这跟access_token是一样的吗?我已经尝试分裂这个没有运气。



任何想法,甚至PHP(!)中的工作代码将是最受欢迎的!谢谢

解决方案

尝试使用这个代码与FB SDK

  require_once'facebook.php'; 

$ appapikey ='xxx';
$ appsecret ='xxx';
$ facebook = new Facebook($ appapikey,$ appsecret);

$ session_key ='xxx'; //这是在要求offline_access扩展权限时返回的无限session_key

$ args = array(
'method'=>'facebook.video.upload',
'v'=>'1.0',
'api_key'=> $ appapikey,
'call_id'=> microtime(true),
'format'=& ',
'session_key'=> $ session_key,
'title'=>'我的视频标题',
'description'=>'我的视频说明'
);

ksort($ args);
$ sig ='';
foreach($ args as $ k => $ v){
$ sig。= $ k。 '='。 $ V;
}
$ sig。= $ appsecret;
$ args ['sig'] = md5($ sig);

$ args [short.wmv] ='@E:\path\to\short.wmv';

$ ch = curl_init();
$ url ='http://api-video.facebook.com/restserver.php?method=facebook.video.upload';
curl_setopt($ ch,CURLOPT_URL,$ url);
curl_setopt($ ch,CURLOPT_HEADER,false);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ ch,CURLOPT_POST,true);
curl_setopt($ ch,CURLOPT_POSTFIELDS,$ args);

$ data = curl_exec($ ch);

print_r($ data); // return xml here

我还发现了一个错误报告今天提交,表示视频上传已经工作并且不能正常工作。这可能是你的代码很好,Facebook的API正在搞砸。



编辑:



尝试以下,似乎已经为几个人工作了。


I'm having lots of issues with uploading videos.

If I try to use https://api-video.facebook.com I am getting a cURL host not found error, if I use http://api-video.facebook.com I get a message to use https://api-video.facebook.com

If I try to use https://api.facebook.com/restserver.php?method=video.upload I get a 101 error code -

<error_msg>Invalid API key</error_msg>

but the API key works for everything else, statuses, comments, likes, fql for the user?

Heres what I am sending:

access_token=XXXX
api_key=XXXX
call_id=1279204007.6003
description=Description+of+this%3F
format=JSON
title=Title%2C+a+title
v=2.0
sig=XXX

I read in the post on the FB developers forum that splitting the session key by | gives you a correct session key? Is this the same as access_token? I have tried splitting this up with no luck.

Any ideas, or even working code in PHP (!) would be most welcome! Thanks

解决方案

Try using this code with the FB SDK

require_once 'facebook.php';

$appapikey = 'xxx';
$appsecret = 'xxx';
$facebook = new Facebook($appapikey, $appsecret);

$session_key = 'xxx'; //this is the infinite session_key returned when asking for the offline_access extended permission

    $args = array(
          'method' => 'facebook.video.upload',
          'v' => '1.0',
          'api_key' => $appapikey,
          'call_id' => microtime(true),
          'format' => 'JSON',
          'session_key' => $session_key,
          'title'       => 'My video title',
          'description' => 'My video description'
    );

      ksort($args);
      $sig = '';
      foreach($args as $k => $v) {
        $sig .= $k . '=' . $v;
      }
      $sig .= $appsecret;
      $args['sig'] = md5($sig);

    $args["short.wmv"] = '@E:\path\to\short.wmv';

    $ch = curl_init();
    $url = 'http://api-video.facebook.com/restserver.php?method=facebook.video.upload';
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $args);

    $data = curl_exec($ch);

    print_r($data); //returned xml here

I also found a bug report submitted today stating that video uploads have been working and not working sporatically. It could be your code is just fine and facebook's APIs are messing up.

EDIT:

Try the following, it seems to have worked for a few people.

这篇关于将视频上传到旧的Facebook REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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