Well, a couple of things to try:

a) instead of constructing your own <entry/>, try sending a copy of one you
previously retrieved (with the appropriate changes, of course);

b) is CURLOPTS_POST a PUT?   It needs a PUT.

c) does CURLOPT_POSTFIELDS x-www-urlencode the XML?  You don't want that -
just a plain XML body.

d) I don't see an If-Match header


Xref:
http://code.google.com/apis/spreadsheets/data/3.0/developers_guide.html#UpdatingListRows



Good luck,
David.


On Tue, Apr 19, 2011 at 9:47 PM, Thimuth <[email protected]> wrote:

> 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.
>

Reply via email to