Getting google error after Get Request (cURL / PHP)

416 views
Skip to first unread message

Fish

unread,
Aug 10, 2009, 8:48:32 AM8/10/09
to Google Contacts API
Hi everyone,

While trying to access the google API through cURL to get my contacts,
I am getting a Google error code 'Bad request - Your client has issued
a malformed or illegal request.'.

Before that, I was actually getting something but which is not the
Atom 1.0 xml expected.

Could you help me, I may be fogetting something in the process.

Here is my code for the request :

$ch = curl_init();

$headers[] = 'Content-Type: application/x-www-form-urlencoded';
$headers[] = 'Authorization: AuthSub token='. $request-
>getParameter('token');
$headers[] = 'User-Agent: Java/1.5.0_06';
$headers[] = 'Host: www.google.com';
$headers[] = 'Accept: text/html, image/gif, image/jpeg, *; q=.2,
*/*; q=.2';
$headers[] = 'Connection: keep-alive';


curl_setopt($ch, CURLOPT_URL, 'www.google.com/m8/feeds/contacts/
default/full HTTP/1.1');
//curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);

$this->result = curl_exec($ch);


The process is : I direct the user to the link to AuthSub which gets
me back a token in a get parameter.

I use this one in the get request above and I expect to get the
response with my contact list, and that does not happen.

Any idea ?

Thanks in advance,

Julian (Google)

unread,
Aug 11, 2009, 11:32:35 AM8/11/09
to Google Contacts API
Reply all
Reply to author
Forward
0 new messages