【问题标题】:Error when trying to upload video on dailymotion with Graph API尝试使用 Graph API 在 dailymotion 上上传视频时出错
【发布时间】:2014-05-10 10:35:21
【问题描述】:

我正在尝试在这里使用图形 API 在 dailymotion 上上传视频:

http://www.dailymotion.com/doc/api/graph-api.html

已通过读写权限成功验证,但尝试使用以下 api 发布方法上传视频时:http://www.dailymotion.com/doc/api/graph-api.html#publishing Getting Errors

stdClass Object ( [error] => stdClass Object ( [code] => 400 [message] => `url' 参数返回无效的内容类型:text/plain,必须是 video/* [type] => invalid_parameter ) )

我正在使用以下 cURL 向 API 发布请求:

$fields = '';
   $data = array(
       "access_token" => $token,
       "url" => "https://www.somesite.com/demo/dailymotion/X.mp4"
    );
   $url = "https://api.dailymotion.com/me/videos";
   foreach($data as $key => $value) { 
      $fields .= $key . '=' . $value . '&'; 
   }
   rtrim($fields, '&');

   $post = curl_init();

   curl_setopt($post, CURLOPT_URL, $url);
   curl_setopt($post, CURLOPT_POST, count($data));
   curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
   curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);

   $result = curl_exec($post);

   curl_close($post);
   print_r(json_decode($result));

请有人帮我解决这个问题。

【问题讨论】:

    标签: php api curl video-processing dailymotion-api


    【解决方案1】:

    我认为您的视频网址有问题,它似乎未被识别为视频:

    invalid content type: text/plain, must be video/* [type] 
    

    您应该使用通过 api 传递的上传 URL:对 /file/upload 执行 HTTP GET 以获取上传 URL,并使用 multipart/form-data content-type 将您的视频与文件中的视频一起发布到该地址场地。使用此 url 测试您的代码时,它有效。

    我有两个 cmets:你为什么不使用 php sdk 呢?它会让你的一切变得更容易!此外,为了发布您的视频,您应该为其指定标题和频道,并将“已发布”设置为 true,在您的数据数组中:

    $data = array(
       "access_token" => $token,
       "channel" => "news",
       "title" => "my title",
       "published"=> True,
       "url" => $videourl
    );
    

    这描述在:http://www.dailymotion.com/doc/api/getting-started.html#publishing-videos 你可以在http://www.dailymotion.com/doc/api/use-cases.html找到一个使用php sdk的用例

    【讨论】:

      猜你喜欢
      • 2014-12-16
      • 2016-08-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-20
      • 1970-01-01
      相关资源
      最近更新 更多