cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

login to google

From: Wes DeBoer <wes_at_wesdeboer.com>
Date: Mon, 09 Jan 2006 14:58:49 -0800

I am trying to use curl in php to login to google adwords and once logged in I
want to be able to go to a specific page but seem to be having troubles with the
cookies and googles redirects.

I can post my login info to google and get logged in to the system with curl,
google will redirect me to an adwords account overview page, but when I try to
the follow that up with a curl request to another page it always redirects me to
another login and I can't post to that login page because it is a redirect and
it seems that the cookies that are stored are not valid cookies for getting to
the requested page. Here is the code that I am at and I have tried many
different options including ssl and referer settings and so on, and nothing
seems to work. Any help would be appreciated.

$url = 'https://www.google.com/accounts/ServiceLoginAuth';
$string =
'ltmpl=login&continue=https://adwords.google.com/select/gaiaauth&followup=https://adwords.google.com/select/gaiaauth&service=adwords&nui=3&fpui=1&ifr=true&rm=hide&ltmpl=login&hl=en-US&alwf=true&GA3T=aZShS9ukGFg&Email=example@gmail.com&Passwd=examplepass';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
$data = curl_exec($ch);

curl_setopt($ch, CURLOPT_URL, 'https://adwords.google.com/select/ReviewInvoices');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
$data = curl_exec($ch);
curl_close($ch);

Wes.

-------------------------------------------------
End Of Webmail Message
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2006-01-10