0
votes

How do you implement https://developers.google.com/youtube/2.0/developers_guide_protocol_deprecated using PHP?

What I tried:

<?php
  $headers = array("PUT /feeds/api/users/default HTTP/1.1",
  "Host: gdata.youtube.com",
  "Content-Type: application/atom+xml",
  "Authorization: Bearer ACCESS_TOKEN",
  "X-GData-Key: key=DEVKEY",
  "Content-length: ".strlen($data),
  $curl = curl_init("https://gdata.youtube.com/feeds/api/users/default?v=2.1");
  curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_TIMEOUT, 10);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PUT');
  curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  curl_setopt($curl, CURLOPT_REFERER, true);
  curl_setopt($curl, CURLOPT_HEADER, 0);
  $returnxxx = curl_exec($curl);
  curl_close($curl);
  echo $returnxxx;
?>

I am missing ACCESS_TOKEN though.

1

1 Answers

1
votes

Associating an unlinked Google Account with a YouTube channel is no longer possible via the APIā€”that's why it's in the deprecated section of the documentation.

The current way of prompting a user to link a Google Account to a channel is described at https://developers.google.com/youtube/create-channel That guide is mobile-focused, but the same process can be kicked off by redirected a user to https://www.youtube.com/create_channel on the desktop.