title: PHP Post with Header and XML Content
body: <p>I want to subscribe a YouTube Channel through the GData API via PHP.</p>
  
  <p><img src="https://i.stack.imgur.com/P1WGn.png" alt="Documentation"></p>
  
  <p>How can i do this post in PHP?</p>
  
  <p>I tried it like this but the page keeps loading forever:</p>
  
  <pre><code>&lt;?php
  
  session_start();
  
  include 'gdata.php' // For $DEVKEY
  
  function post_xml($url, $xml) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLINFO_HEADER_OUT, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, Array(
    "Content-Type: application/atom+xml",
    "Content-Length: 1024",
    "Authorization: Bearer $token",
    "GData-Version: 2",
    "X-GData-Key: key=$DEVKEY"));
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, array('data' =&gt; $xml );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  
    $result = curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);
    return $result;
  }    
  
  $token = $_SESSION['token'];
  
  $xml = '&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;entry xmlns="http://www.w3.org/2005/Atom"
    xmlns:yt="http://gdata.youtube.com/schemas/2007"&gt;
      &lt;category scheme="http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat"
        term="channel"/&gt;
      &lt;yt:username&gt;GoogleDevelopers&lt;/yt:username&gt;
  &lt;/entry&gt;';
  
  $url = 'https://gdata.youtube.com/feeds/api/users/default/subscriptions';
  
  echo post_xml($url, $xml);
  
  ?&gt;
  </code></pre>
  
  <p>In HttpRequester i already managed it to do a HTTP Post Request and it worked. I think the problem is the content of the Request. How do i properly give the text which is in "Content" (look at the screenshot) via PHP (cURL)?</p>
  
  <p><img src="https://i.stack.imgur.com/Dqtuz.png" alt="HttpRequester"></p>
  
  <p>Thanks :)</p>