如何使用断点续传API v3在YouTube上上传文件 [英] How to upload files on YouTube using resumable upload API v3

查看:109
本文介绍了如何使用断点续传API v3在YouTube上上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码不起作用,如何使用它在YouTube上上传文件?

The following code does not work, how can I use it to upload files on YouTube?

    $service_url = 'https://www.googleapis.com/upload/youtube/v3/videos?uploadType=resumable&part=snippet,status';
    $c = curl_init($service_url);
    $curl_post_data = array(
        "Authorization" => $val,
        "Content-Length" => '275',
        "Content-Type" => 'application/json; charset=UTF-8',
        "X-Upload-Content-Length" => '2394849',
        "X-Upload-Content-Type" => 'video/mov'
    );

    curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($c, CURLOPT_POST, true);
    curl_setopt($c, CURLOPT_POSTFIELDS, $curl_post_data);
    $curl_resp = curl_exec($c);

    curl_close($c);
    echo $curl_resp;
}else {
  $authUrl = $client->createAuthUrl();
  print "<a href='$authUrl'>upload</a>";
}



?>

请参考以下问题,该问题是该问题的完整版本 Q

please refer to following question which is complete version of this question Q

推荐答案

如果您是在本地尝试,请尝试在Dev Console中创建其他已安装的应用程序(似乎是通过localhost重定向这样做的),然后将其作为尝试在服务器上使用Web应用程序.

Try creating a installed application as other in Dev Console if you are trying it locally (you seem to do it so with localhost redirect), then try it as a web application when you try on server.

确保每次设置正确的凭据.

Make sure you set the right credentials each time.

这篇关于如何使用断点续传API v3在YouTube上上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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