Jump to content

Google Analytics Login Curl Script For Adsense Reports


PyraX

Recommended Posts

Hello,

 

I am trying to make a php curl script that can login and download csv adsense performance reports that are not accessable through the API (to my knowledge).

 

The part I get stuck on is login into google analytics.

Have tried for hours using existing scripts of the net but cant seem to get them to work.

 

Can anyone help or have a script that can do this?

 

Thanks in advance

PyraX

 

try this pal........

<?php
/* "AdSense totals sent via SMS to cellphone" 
http://www.webmasterworld.com/forum89/5349.htm

"Follow your Adsense earnings with an RSS reader" 
http://curl.askapache.com/libcurl/php/examples/rss-adsense.html 

"Auto-Login to Google Analytics to impress Clients"
http://www.askapache.com/webmaster/login-google-analytics.html */

// Uncomment to only allow from IP 1.1.1.1
// if($_SERVER['REMOTE_ADDR'] !== '1.1.1.1') die();
$username=urlencode('[email protected]');
$password="mypassword";
$gacookie="./.gacookie";

$postdata="Email=$username&Passwd=$password&GA3T=5AS_gBsvDHI&nui=15&fpui=3&askapache=http://www.askapache.com/"
."&service=adsense&ifr=true&rm=hide&itmpl=true&hl=en_US&alwf=true&continue=https://www.google.com/adsense/report/overview&null=Sign in";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,"https://www.google.com/accounts/ServiceLoginBoxAuth");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $gacookie);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $gacookie);
curl_setopt ($ch, CURLOPT_REFERER, 'https://www.google.com/adsense/report/overview');
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$AskApache_result = curl_exec ($ch);
curl_close($ch);
echo $AskApache_result;
unlink($gacookie);
exit;
?>

donate! web site info
File upload with ASP

just done some research and guess what i got a good one bro

 

http://www.electrictoolbox.com/google-analytics-api-and-php/

 

apparently the above used heavily and properly supported buy hundreds off php programmers.

Thanks, I have tried that one too lol. The issue I have is that I dont want to login to the api, I need to login to analytics normally then once logged in access a report via a link like:

 

https://www.google.com/analytics/reporting/export?fmt=2&id=5941183&pdr=20090829-20090928&cmp=average&rpt=ExitsReport

 

one that the API does not currently support

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.