I'm trying to edit a google spreadsheet using the following php code. But
it gives me HTTP 400 error. Can anybody figure out what's the error here or
anybody have a better way to do this ?
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// construct the headers with the pre-acquired google auth token
$headers = array(
"Content-Type: application/atom+xml",
"Authorization: GoogleLogin auth=" . $this->token,
"GData-Version: 3.0",
);
$fields = '<entry xmlns="http://www.w3.org/2005/Atom"
gd:etag=\'"QQFEF1sdUyt7ImA4Cg.."\'>
<id>https://spreadsheets.google.com/feeds/list/tBfPhxo_vMvgY6iPSjZzD-w/od6/private/full/chk2m</id>
<updated>2011-04-19T07:17:57.281Z</updated>
<category scheme="http://schemas.google.com/spreadsheets/2006"
term="http://schemas.google.com/spreadsheets/2006#list"/>
<title>2</title><content>name: 3, jobtitle: 2, description: 2,
id: 2</content>
<link rel="self" type="application/atom+xml"
href="https://spreadsheets.google.com/feeds/list/tBfPhxo_vMvgY6iPSjZzD-w/od6/private/full/chk2m"/>
<link rel="edit" type="application/atom+xml"
href="https://spreadsheets.google.com/feeds/list/tBfPhxo_vMvgY6iPSjZzD-w/od6/private/full/chk2m/4cgbdjajg"/>
<gsx:name>New Name</gsx:name>
</entry>';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,
'https://spreadsheets.google.com/feeds/list/tBfPhxo_vMvgY6iPSjZzD-w/od6/private/full/chk2m/4cgbdjajg/');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $fields);
$response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
echo $response;
----------------------------------------------------------------------------------------------------------------------------------
Thanks.