How to upload files on YouTube using resumable upload API v3

不问归期 提交于 2019-12-13 06:53:06

问题


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>";
}



?>

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


回答1:


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.



来源:https://stackoverflow.com/questions/17008987/how-to-upload-files-on-youtube-using-resumable-upload-api-v3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!