J888
J888

Reputation: 1964

How to upload files on YouTube using resumable upload API v3

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

Upvotes: 0

Views: 969

Answers (1)

Ibrahim Ulukaya
Ibrahim Ulukaya

Reputation: 12877

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.

Upvotes: 1

Related Questions