Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Gathering, Interpreting & Using AdSense Earnings Information

A script to automate this process

7:04 pm on May 27, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 6, 2007
votes: 0

I use my AdSense Earnings information to monitor my progress, supplement my internal reports and to enable me to perform certain performance calculations.

I gather my earnings information by hand to enter into a database on my website to perform most of these functions automatically based on scripts I have written.

Originially I had thought that there were only two ways to gather this information. One could log into the adsense website to read the earning reports and enter this information in by hand (manual and argious), or one could write a script to do the same (prohibited). Since the later could potentially get you banned, that only left me with one viable option.

That was until I had a realization that there was a second viable option. One is allowed to generate custom reports, and to have those reports emailed to them self daily.

In theory one could have their reports emailed to them by AdSense, and to write a script that would read the email reports and input this information into the database automatically. This option is not prohibited, and is complete automatic.

Therefore, I'm developing a script to automate the process of inputing adsense earnings and statistics data into a database on my website.

To start off, I'm working in a PHP and MySQL environment.

I started by setting up an email account with my hosting company that would write incoming emails to a non-public file on my server, "inbox.txt". Only emails to that specific address are affected.

Then, in the AdSense website, I setup a basic report of the previous day's earnings to have emailed to my specail email address daily.

AdSense sends out the reports in the morning (PST). The reports come in a .csv file that is then zipped and stored as an attachment.

I created a file that will read my inbox.txt file, to read the reports, and to grab the latest AdSense reports email:





echo $zip;

I'm now at a point where I'm stuck. I have the contents of the zip file, but I don't know how to read it.

My understanding is that PHP can not understand the contents of zip files without additional libraries. I don't know how to install these libraries. But I'm hoping that since this is such a small .zip file (only about 300 characters long) and that I'm only trying to read it, that I'm hoping installation of these libraries is over kill.

Once I get over the zip hurdle, I plan on adding to the script to where it will read the contents of the enclosed csv file, and that contents to the database, and to clear out the inbox.txt file.

I'm writing this post in hopes that others might find this script useful, and its information useful, and might join me in helping me over this hurdle. And maybe develop additional features for it.

1:07 pm on May 30, 2007 (gmt 0)

Senior Member

joined:Nov 12, 2005
votes: 0

You should be able to run an unzipping utility (varies based on your computer-might want to try unzip) from the command line using exec [php.net], or one of the similar functions. Once the file is in a readable format, you can search the info and update to your db.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members