Welcome to WebmasterWorld Guest from 126.96.36.199
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:
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.