title: YouTube API : Error 400 (Bad Request)
body: <p>I have a page on my localhost from where users can upload videos. Now I'd like to implement the function, where admins can make those videos public (users must upload them as private videos).
  Now for that, first of all I need to get a list of all videos on channel (including the private ones). I tried this code:</p>
  
  <pre><code>    $data = '&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;/entry&gt;';
      $headers = array( "Authorization: GoogleLogin auth=".$authvalue,
                   "GData-Version: 2",
                   "X-GData-Key: key=".$youtube_key,
                   "Content-length: ".strlen( $data ),
                   "Content-Type: application/atom+xml; charset=UTF-8");
      $curl = curl_init( "https://gdata.youtube.com/feeds/api/users/default/uploads");
      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_POST, 1 );
  curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, 1 );
  curl_setopt( $curl, CURLOPT_HTTPHEADER, $headers );
  curl_setopt( $curl, CURLOPT_POSTFIELDS, $data );
  curl_setopt( $curl, CURLOPT_REFERER, true );
  curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, 1 );
  curl_setopt( $curl, CURLOPT_HEADER, 0 );
      $response = curl_exec($curl);
   curl_close($curl);
  </code></pre>
  
  <p>which returns with this error:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=en&gt;
    &lt;meta charset=utf-8&gt;
    &lt;meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width"&gt;
    &lt;title&gt;Error 400 (Bad Request)!!1&lt;/title&gt;
    &lt;style&gt;
      *{margin:....
  </code></pre>
  
  <p>I couldn't find the proper form of headers for requesting a list of user videos, so I used the one which I apply for uploading videos (and which works, so I am certain there is not a problem with user authentication).</p>
  
  <p>If you could tell me what I am doing wrong or just point me to an example of working video listing, I'd be very grateful.</p>
  
  <p>edit:
  curl_error returns an empty string, curl_info returns this:</p>
  
  <pre><code>array (size=26)
    'url' =&gt; string 'https://uploads.gdata.youtube.com/feeds/api/users/.../uploads' (length=80)
    'content_type' =&gt; string 'text/html; charset=UTF-8' (length=24)
    'http_code' =&gt; int 400
    'header_size' =&gt; int 597
    'request_size' =&gt; int 1747
    'filetime' =&gt; int -1
    'ssl_verify_result' =&gt; int 20
    'redirect_count' =&gt; int 1
    'total_time' =&gt; float 0.639
    'namelookup_time' =&gt; float 0.047
    'connect_time' =&gt; float 0.078
    'pretransfer_time' =&gt; float 0.172
    'size_upload' =&gt; float 0
    'size_download' =&gt; float 925
    'speed_download' =&gt; float 1447
    'speed_upload' =&gt; float 0
    'download_content_length' =&gt; float 925
    'upload_content_length' =&gt; float 0
    'starttransfer_time' =&gt; float 0.203
    'redirect_time' =&gt; float 0.436
    'certinfo' =&gt; 
      array (size=0)
        empty
    'primary_ip' =&gt; string '173.194.70.117' (length=14)
    'primary_port' =&gt; int 443
    'local_ip' =&gt; string '10.0.0.33' (length=9)
    'local_port' =&gt; int 53639
    'redirect_url' =&gt; string '' (length=0)
  </code></pre>