Forum Moderators: coopster
<?php
// The XML we are wanting to send
$xml = '
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:yt="http://gdata.youtube.com/schemas/2007">
<title type="text">Sports Highlights Playlist</title>
<summary>A selection of sports highlights</summary>
</entry>
';
$curlheader = array();
$curlheader[] = "POST /feeds/api/users/default/playlists HTTP/1.1\r\n";
$curlheader[] = "Host: gdata.youtube.com\r\n";
$curlheader[] = "Content-Type: application/atom+xml\r\n";
$curlheader[] = "Content-length: ". strlen($xml). "\r\n";
$curlheader[] = "Authorization: AuthSub \"". $key. "\"\r\n";
$curlheader[] = "GData-Version: 2\r\n";
$curlheader[] = "X-GData-Key: key=". $anotherKey. "\r\n";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://gdata.youtube.com/feeds/api/users/default/playlists');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
curl_setopt($curl, CURLOPT_HTTPHEADER, $curlheader);
$output = curl_exec($curl);
curl_close($curl);
echo $output;
?> I keep getting the error POST requests require a Content-length header, despite it being in there. Is there something I'm missing with my code, because if there is, I certainly can't see it.