This code returns 400 error Response contains no content type
Any ideas? Thank you in advance.
function create($url, $token)
{
$contactAtom = new DOMDocument();
$contactAtom->formatOutput = true; $topLevel = $contactAtom-
>createElement('atom:entry');
$topLevel->setAttribute('xmlns:atom', 'http://www.w3.org/2005/
Atom');
$topLevel->setAttribute('xmlns:gd', 'http://schemas.google.com/g/
2005');
$contactAtom->appendChild($topLevel);
$category = $contactAtom->createElement('atom:category');
$category->setAttribute('scheme', 'http://schemas.google.com/g/
2005#kind');
$category->setAttribute('term', 'http://schemas.google.com/contact/
2008#contact');
$topLevel->appendChild($category);
$name = $contactAtom->createElement('gd:name');
$givenName = $contactAtom->createElement('gd:givenName',
"Elizabeth");
$familyName = $contactAtom->createElement('gd:familyName',
"Bennett");
$fullName = $contactAtom->createElement('gd:fullName', "Elizabeth
Bennett");
$name->appendChild($givenName);
$name->appendChild($familyName);
$name->appendChild($fullName);
$topLevel->appendChild($name);
print $contactAtom->saveXML();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $contactAtom);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curlheader[0] = sprintf("Authorization: AuthSub token=\"%s\"/
n GData-Version:\"3.0\" ", $token);
$curlheader[1] = 'Content-Type: application/atom+xml';
curl_setopt($ch, CURLOPT_HTTPHEADER, $curlheader);
curl_setopt($ch, CURLOPT_HEADER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
$sXML =create('https://www.google.com/m8/feeds/contacts/default/full',
$tokd);
print_r ($sXML);
--
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/contacts/community/forum.html