Hello. I am using cURL to try and direct upload post data to
https://gdata.youtube.com/feeds/api/users/default/uploads. I am
setting Content-Type: application/atom+xml in my header but when I
make the call I get back the error: Content-Type: application/x-www-
form-urlencoded is not a valid input type. I have included my cURL
code below
$postvals = array('access_token' => $video_info['token'],
'youtube_username' => $video_info['uname'],
'developer_key' => 'MY-DEVELOPER-KEY',
'video_filename' => 'Test Video',
'boundary_string' => '--er0er89g80er',
'video_content_type' => 'video/avi',
'Binary File Data' => '@'.$video_info['filename'],
'API_XML_Request' => $string
);
$curlheader[0] = "Authorization: Bearer " . $video_info['token'];
$curlheader[1] = "Developer-Key: MY-DEVELOPER-KEY";
$curlheader[3] = "Content-Transfer-Encoding: binary" ;
$curlheader[4] = "Content-Type: application/atom+xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_VERBOSE, 1); // comment after dev
curl_setopt($ch, CURLOPT_URL, 'https://gdata.youtube.com/feeds/api/
users/default/uploads');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attributes);
#curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($attributes));
#curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($this->request));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
For the XML portion of the POST I have
$string = "<?xml version='1.0'?>
<entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://
search.yahoo.com/mrss/' xmlns:yt='http://gdata.youtube.com/schemas/
2007'>
<media:group>
<media:title type='plain'>Video Title</media:title>
<media:description type='plain'>description</media:description>
<media:category scheme='http://gdata.youtube.com/schemas/2007/
categories.cat'>Autos</media:category>
<media:keywords>k1,k2,k3,k4</media:keywords>
</media:group>
</entry>";
What am I doing wrong? The documentation isn't all that clear on how
to formulate an upload request.
--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.
No comments:
Post a Comment