|
Sylvain Beauregard - 2012-11-22 19:02:33
Hi!
Just wanted to thank you for this great work.
I've been trying to figure out how to download my Adsense data report for days using the Google code... and I couldn't figure it out, especially with their confusing different naming conventions for codes/keys between the documentation and their actual console.
This morning, with the help of your great library, I was able to not only access my Google Adsense data but to generate the perfectly formatted report for my needs (thanks on Google API Explorer that helped a lot for the return structure).
I was able to complete that within 2 hours (including the reading initial part).
Now, I'll take about another hour to create my MySQL tables and dump the data... and I'll have it run nightly through CRON to have my own customized reporting.
Manuel Lemos - 2012-11-22 22:51:04 - In reply to message 1 from Sylvain Beauregard
Yes, Google APIs are confusing because they used to have APIs based on GData which they are not deprecating.
Sylvain Beauregard - 2012-11-22 23:25:18 - In reply to message 2 from Manuel Lemos
Yes.
All the script is complete now. But I have an issue when it comes to execute it from the UNIX Command-line. It doesn't generate any error but the communication stops of course when Google tries to reconnect with the script. No data has been processed.
I've tried with Lynx... but it doesn't want to process either. I'll look into other possible browsers available.
Unless you have any other idea?
Normally, the solution would be use a Service Account API Key... but Adsense doesn't support those API keys apparently.
Manuel Lemos - 2012-11-23 01:11:44 - In reply to message 3 from Sylvain Beauregard
After the user has authorized the API access, you can store the access_token value and use it even when the user is not online to call the API. Just set the access_token class variable from the stored value.
In that case you no longer have to call the Process function, as that is used only to redirect the user to Google site to ask for permission again.
Sylvain Beauregard - 2012-11-23 17:52:04 - In reply to message 4 from Manuel Lemos
Yes, that works... but only for a short period of time... even less than the default 6h token life set by the Google Auth process.
But yes, once I renewed the token through a regular Web call, I can use that token string in a CRON job. But 3 or 4 hours later, I get an error 401- Invalid credentials.
For now, it's okay... I can easily do with that limitation by running it daily through a Windows automated job on my desktop.
But ideally, I'd like it to be a standalone solution. I'll keep looking, but at least right now I have a working solution, but it won't be a priority for now.
Manuel Lemos - 2012-11-24 03:40:29 - In reply to message 5 from Sylvain Beauregard
Probably that token is set to expire in that period.
Nowadays even Facebook tokens expire after 2 months.
You just need to plan your workflow to handle expired or revoked tokens.
|