Forum Moderators: martinibuster

Message Too Old, No Replies

Adsense php login script

         

jcondal

3:43 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



I'm trying to login to adsense via php, and I found this script, by amznVibe posted last month

$username="your-username";
$password="your-password";
$postdata="Email=".urlencode($username)."&Passwd=%09".urlencode($password)."&service=adsense&ifr=true&rmShown=1&null=Sign+in";
$agent="User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)";
$cookie=dirname(__FILE__)."/cookiefile";
putenv('TZ=US/Pacific'); $randate=mktime(0, 0, 0, date("m"), date("d")-rand(3,26),date("Y"));

$chain=array(
"https://www.google.com/accounts/ServiceloginBoxAuth",
"https://www.google.com/accounts/CheckCookie?continue=https%3A%2F%2Fwww.google.com%2Fadsense%2Flogin-box-gaiaauth&followup=https%3A%2F%2Fwww.google.com%2Fadsense%2Flogin-box-gaiaauth&service=adsense&hl=en_US&chtml=loginDoneHtml",
"https://www.google.com/adsense/report/aggregate?sortColumn=0&reverseSort=false&storedReportId=-1&isOldReport=false&product=afc&dateRange.simpleDate=thismonth&dateRange.dateRangeType=custom&dateRange.customDate.start.month="
.date("n",$randate)."&dateRange.customDate.start.day=".date("j",$randate)."&dateRange.customDate.start.year=".date("Y",$randate)."&dateRange.customDate.end.month=".date("n")."&dateRange.customDate.end.day=".date("j")."&dateRange.customDate.end.year=".date("Y")
."&unitPref=page&reportType=property&searchField=&groupByPref=date&csv=true&outputFormat=TSV_EXCEL"
);

$ch = curl_init();
foreach ($chain as $url)
{
curl_setopt ($ch, CURLOPT_URL,$url);
curl_setopt ($ch, CURLOPT_USERAGENT, $agent);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_TIMEOUT, 35);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
}
curl_close($ch);
// echo "<html>".$result;

Has the login changed again? Because this script won't work for me. I was able to login using the headers I grabbed off of the LiveHTTP Headers plugin, but the CheckCookie request still fails for me. It says my browser doesn't support cookies. I've checked, and the cookie file is there, and open for writing.

Anybody have this working?

greatstart

4:00 pm on Jun 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nope, that script is way too complicated. Here's a simple one that works well for me:

<form name="form1" method="post" action="https://www.google.com/adsense/login.do">
<input type="hidden" name="username" value="YOUR_EMAIL">
<input type="hidden" name="password" value="YOUR_PASSWORD">
<input type="hidden" name="destination" value="">
<input type="submit" value="AdSense Login">
</form>

Jafo

4:46 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



Nope, that script is way too complicated. Here's a simple one that works well for me:

That is not a script, that is an HTML form.

wyweb

5:51 pm on Jun 26, 2007 (gmt 0)



<form name="form1" method="post" action="https://www.google.com/adsense/login.do">
<input type="hidden" name="username" value="YOUR_EMAIL">
<input type="hidden" name="password" value="YOUR_PASSWORD">
<input type="hidden" name="destination" value="">
<input type="submit" value="AdSense Login">
</form>

Might help to add this:

<body>
<script language="javascript">
document.form1.submit();
</script>
</body>

jcondal

5:59 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



To be clear, I'm looking to do this via PHP, and I think the Google login process has changed recently, which renders the script above inoperable. I wanted to know if others are noticing the same thing, and if anyone has found a workaround. I don't need to write html or submit a form.

jatar_k

7:23 pm on Jun 26, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



there was this thread a little while ago
[webmasterworld.com...]

jcondal

10:07 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



Yes. This is the script I found and posted above, but it doesn't seem to be working. I was wondering if those who tried it before are still getting the right results. I haven't been able to get it to work this week. (Never tried it before)