Note that there are some explanatory texts on larger screens.

plurals
  1. POYoutube Oauth 2.0 API Videos Upload Failed
    text
    copied!<p>So i managed to built oauth 2.0 youtube video upload, but everytime i upload a video i get an HTTP 400 ERROR with a invalid request.</p> <p>But the weirdest thing is that the video is uploading to youtube while having : Failed (upload aborted).</p> <p>im not using any framework, cause google doesnt have yet any to oauth 2.0, so i built all of my code on my own.</p> <p>And also i did managed to send comments, and stuff.... the only problem is the video upload itself.</p> <p>My code:</p> <pre><code>public function uploadVideo($video, $title, $description, $category, $keywords) { $url = 'http://uploads.gdata.youtube.com/feeds/api/users/FacebookDevelopersIL/uploads'; $boundary = uniqid(); $accessToken = $this-&gt;refreshAccessToken("13", "11313", 'REFRESHTOKEN'); $xmlString = "&lt;?xml version='1.0'?&gt;&lt;entry xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:yt='http://gdata.youtube.com/schemas/2007'&gt;&lt;media:group&gt;&lt;media:title type='plain'&gt;".$title."&lt;/media:title&gt;&lt;media:description type='plain'&gt;".$description."&lt;/media:description&gt; &lt;media:category scheme='http://gdata.youtube.com/schemas/2007/categories.cat'&gt;".$category."&lt;/media:category&gt;&lt;media:keywords&gt;".$keywords."&lt;/media:keywords&gt;&lt;/media:group&gt;&lt;/entry&gt;"; $videoData = file_get_contents($video); $headers = array( 'POST /feeds/api/users/FacebookDevelopersIL/uploads HTTP/1.1', 'Host: uploads.gdata.youtube.com', 'Authorization: Bearer '.$accessToken, 'GData-Version: 2', 'X-GData-Key: key='.YOUTUBE_SRM_DEVELOPER_KEY, 'Slug: IMG_0047.mp4', 'Content-Type: multipart/related; boundary='.$boundary, 'Content-Length:'.strlen($videoData), 'Connection: close' ); $postData = "--".$boundary . "\r\n" ."Content-Type: application/atom+xml; charset=UTF-8\r\n\r\n" .$xmlString . "\r\n" ."--".$boundary . "\r\n" ."Content-Type: video/mp4\r\n" ."Content-Transfer-Encoding: binary\r\n\r\n" .$videoData . "\r\n" ."--".$boundary . "--"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); $response = curl_exec($ch); curl_close($ch); Trace::dump($response); } </code></pre> <p>The error im getting: HTTP/1.1 400 Bad Request Server: HTTP Upload Server Built on May 7 2012 18:16:42 (1336439802) Content-Type: text/html; charset=UTF-8 X-GUploader-UploadID: AEnB2Uq7cHcf6rS4bcamu18ChAF3gnKJqsF6U_dk2qB4WR9GhAoTL_-iUejitgead-Gh-1fpJcke1z68TAxoopS2vYiGmCW69A Date: Thu, 10 May 2012 11:55:24 GMT Pragma: no-cache Expires: Fri, 01 Jan 1990 00:00:00 GMT Cache-Control: no-cache, no-store, must-revalidate Content-Length: 15 Connection: close</p> <p>Invalid Request</p> <p>thanx everyone!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload