以下代码不起作用,如何使用它在 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