Zero values or cached values of current day returned from the Adsense Mangement API

41 views
Skip to first unread message

Max Glaser

unread,
Dec 28, 2011, 9:53:39 AM12/28/11
to AdSense API Forum
For several years I used an own script to scan the main page of the
old AdSense control panel interface to get several times a day the
most important parameters (page views, clicks, earnings).

Since middle November, the old Interface has been shut downed.

Now I found theoretically the correct way to obtain these
Information: the new Adsense Mangement API!

I obtain via API the correct values for "yesterday", but when I set
the date to "today" I do not get any result on the JSON response, or
the first time I get some values, but after that, all day I obtain the
same values! I seems that the API server cannot return the "last real-
time" values.

But in the other hand, there is an App on the Android Market (AdSense
Dashbord) which uses this API and returns relative accurate values.

I am using the PHP AdSense API Library, and I really don't know, what
I making wrong! I am using the reports / generate functions!

Thank You in advance for any hint!

Regards,
Max Glaser

Silvano Luciani

unread,
Dec 28, 2011, 11:21:45 AM12/28/11
to AdSense API Forum
Hello Max,

a couple of questions to have a better understanding of what could be
the problem:

- The API is returning values which are different from the values that
appear in the AdSense frontend?

- Can you reproduce the same problem querying the API using the Google
API explorer?
https://code.google.com/apis/explorer/#_s=adsense&_v=v1.1&_m=reports.generate

Cheers,
Silvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

Max Glaser

unread,
Dec 29, 2011, 5:20:32 PM12/29/11
to AdSense API Forum
Hello Silvano,

Thank You very much for your replay!

1. As I told you, the values of "yesterday" are the same as the
AdSense FrontEnd. But y do not get any result for "today"

here an example of the returned values (JSON / PHP Array)

Array
(
[kind] => adsense#report
[totalMatchedRows] => 1
[headers] => Array
(
[0] => Array
(
[name] => DATE
[type] => DIMENSION
)

[1] => Array
(
[name] => PAGE_VIEWS
[type] => METRIC_TALLY
)

[2] => Array
(
[name] => CLICKS
[type] => METRIC_TALLY
)

[3] => Array
(
[name] => EARNINGS
[type] => METRIC_CURRENCY
[currency] => USD
)

)

[rows] => Array
(
[0] => Array
(
[0] => 2011-12-28
[1] => xxxxx
[2] => yyyyy
[3] => zzzz.zz
)

)

[totals] => Array
(
[0] =>
[1] => xxxxx
[2] => yyyyy
[3] => zzzz.zz
)

[averages] => Array
(
[0] =>
[1] => xxxxx
[2] => yyyyy
[3] => zzzz.zz
)

)

The date parameter was from 2011-12-28 to 2011-12-29

But I only get 1 row. Sometimes I got the second raw, but the values
remained the same all day.


2. Now I am on the road, so I have no time to experiment with the
Google API explorer...


Thank You!
Max Glaser

Silvano Luciani

unread,
Dec 30, 2011, 5:22:05 AM12/30/11
to AdSense API Forum
Hello Max,

thanks for answering my questions. We will look into your issue and I
will update you during the next week.

Cheers,
Silvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

Max Glaser

unread,
Dec 30, 2011, 9:17:25 AM12/30/11
to AdSense API Forum
Hello Silvano,

Thank You!

OK, the next week I will have more time to make some more tests too...

Happy New Year 2012!

Regards,
Max Glaser

Silvano Luciani

unread,
Jan 5, 2012, 8:42:35 AM1/5/12
to AdSense API Forum
Hello Max,

I've been extensively checking your issue: we always return fresh
values for reports, there is only a tiny level of caching with a
lifetime of few seconds.
If the values are actually changing during the day and you can see the
changes in the AdSense frontend but not in the responses from the API,
then my guess is that somewhere on your side you are caching those
responses, do you think that is possible?

Cheers,
SIlvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

Max Glaser

unread,
Jan 5, 2012, 9:08:33 AM1/5/12
to AdSense API Forum
Hello SIlvano,
I am using the oficial PHP libraries of the AdSense Management API, I
suppose there is no caching functionality on the php client side...
I have the impression, that it depends on the AdSense server that
responds my requests. When I make a request from my local test
equipment, in a different location of the hosted script, I get some
times other results for "today" the "yesterday" results are allways
the same.

Anyway, I will double check my php local / hosted configuration.

Thank You!
Max Glaser

Max Glaser

unread,
Jan 9, 2012, 9:31:05 AM1/9/12
to AdSense API Forum
Hello Silvano,

1. Now i am getting the same values from my test environment and the
hosted scripts.

2. Your right, the API results have only a delay of few seconds
compared to the AdSense Frontend.

3. But I am sill receiving cached results for reports of
endDate="today". I suspect, the AdSense API server is caching URLs or
the PHP library of the AdSense Management API is sending some
parameter on the curl HTTP Request to do it.

Example:
First, I send a report request, for example with the parameters
startDate=2012-01-09 and endDate=2012-01-09. I receive the current
values from the AdSense Frontpage.

When I re-send the same report request, also THE SAME URL during the
day, I always get the first one values, also some kind of cached
values.

Now, when I change only one URL parameter, for example
startDate=2012-01-08, I get the newer values from the AdSense
Frontpage. But, every new report request with of this URL delivers the
same values.

I hope, you can understand what I mean, and now you can find the
solution to this problem.

Regards,
Max Glaser



On Jan 5, 9:42 am, Silvano Luciani <silvano.luci...@google.com> wrote:

Chirag Shah

unread,
Jan 11, 2012, 12:34:59 AM1/11/12
to adsen...@googlegroups.com
Hey Max,

Thank you for reporting this!

I am having trouble reproducing this issue, but in the mean time can you try the latest build and see if it fixes the issue you're seeing?

Thank you!
Chirag

Max Glaser

unread,
Jan 11, 2012, 11:02:10 AM1/11/12
to AdSense API Forum
Hello Chirag,

Now I am using the latest build, but I still have the same problem. On
all builds I need to set CURLOPT_SSL_VERIFYPEER => false (src/io/
apiCurlIO.php, line 30) on the Google API in other to avoid the
following error:

Runtime error: HTTP Error: (0) SSL certificate problem, verify that
the CA cert is OK. Details: error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed #0

Could be this the origin of the caching problem?

Thanks for your help!

Regards,
Max Glaser

On Jan 11, 1:34 am, Chirag Shah <chir...@google.com> wrote:
> Hey Max,
>
> Thank you for reporting this!
>
> I am having trouble reproducing this issue, but in the mean time can you
> try the latest build and see if it fixes the issue you're seeing?http://code.google.com/p/google-api-php-client/downloads/detail?name=...
>
> Thank you!
> Chirag

Silvano Luciani

unread,
Jan 11, 2012, 12:53:43 PM1/11/12
to AdSense API Forum
Hello Max,

for the certificate verify issue please check the FAQ of the Google
APIs PHP Client Library for an optimal solution:
http://code.google.com/p/google-api-php-client/wiki/FAQ

We are investigating the cache issue, I will update you on this thread
when we'll know more.

Cheers,
Silvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

Chirag Shah

unread,
Jan 11, 2012, 12:42:45 PM1/11/12
to adsen...@googlegroups.com
On Wed, Jan 11, 2012 at 8:02 AM, Max Glaser <max.g...@gmail.com> wrote:
Hello Chirag,

Now I am using the latest build, but I still have the same problem. On
Can you try to clear out your cache first. (This is typically done by deleting /tmp/apiClient)
 
all builds I need to set CURLOPT_SSL_VERIFYPEER => false (src/io/
apiCurlIO.php, line 30) on the Google API in other to avoid the
following error:
You shouldn't change that value to false. VERIFYPEER should be enabled to mitigate man-in-the-middle attacks. 

Runtime error: HTTP Error: (0) SSL certificate problem, verify that
the CA cert is OK. Details: error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed #0
I have a common solution to this problem here:

Could be this the origin of the caching problem?
No it seems to be un-related. Try wiping out the cache, and try again. 

Thanks for your help!

Regards,
Max Glaser

On Jan 11, 1:34 am, Chirag Shah <chir...@google.com> wrote:
> Hey Max,
>
> Thank you for reporting this!
>
> I am having trouble reproducing this issue, but in the mean time can you
> try the latest build and see if it fixes the issue you're seeing?http://code.google.com/p/google-api-php-client/downloads/detail?name=...
>
> Thank you!
> Chirag

--
You received this message because you are subscribed to the Google Groups "AdSense API Forum" group.
To post to this group, send email to adsen...@googlegroups.com.
To unsubscribe from this group, send email to adsense-api...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/adsense-api?hl=en.


Nick Toumpelis

unread,
Feb 14, 2012, 5:22:23 AM2/14/12
to adsen...@googlegroups.com
Hi Silvano,

we're also seeing what seems to be a caching issue with today's data. There seems to be a huge disparity especially at particular times in the evening.

Thanks,

Nick

Silvano Luciani

unread,
Feb 14, 2012, 7:03:50 AM2/14/12
to AdSense API Forum
Hello Nick,

are you using the Google APIs PHP Client Library? If that's the case,
have you tried to update to the latest version and clear the cache
after the upgrade?

Cheers,
Silvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

Nick Toumpelis

unread,
Feb 14, 2012, 7:44:50 AM2/14/12
to adsen...@googlegroups.com
Hi Silvano,

I'm using the API from an iOS app using the AFNetworking library.

Thanks,

Nick

Silvano Luciani

unread,
Feb 14, 2012, 8:37:36 AM2/14/12
to AdSense API Forum
Hello Nick,

the API results should have a delay of few seconds compared to the
AdSense Frontend, in the case of Max the caching problem was in the
PHP Client Library, I'm wondering if it's the same with the library
you're using.

Could you check if using the Google APIs Explorer to query the API you
experience the same discrepancy?
https://code.google.com/apis/explorer/#_s=adsense&_v=v1.1

Cheers,
Silvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

Nick Toumpelis

unread,
Feb 14, 2012, 8:40:38 AM2/14/12
to adsen...@googlegroups.com
I will. Thanks, Silvano.

Max Glaser

unread,
Feb 14, 2012, 9:26:30 AM2/14/12
to AdSense API Forum
Hi Silvano,

Do you have some news on this issue? We still have the same
behaivoir: The server is caching the results for the today' s report
when we use the same URL at different day times. The workaround we are
using now is to set different dates ranges ( d1 - today, d2 - today,
etc.) to create a new requesting URL in order to obtain the newest
values.

Regards,
Max

Silvano Luciani

unread,
Feb 14, 2012, 12:17:50 PM2/14/12
to AdSense API Forum
Hello Max,

I'm sorry but as we didn't hear back from you since the last reply of
Chirag, I thought that the issue was solved.

Have you tried to wipe out the cache as Chirag suggested? Can you
replicate the problem using the Google API Explorer to query the API?

Cheers,
Silvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

Nick Toumpelis

unread,
Feb 15, 2012, 6:19:52 AM2/15/12
to adsen...@googlegroups.com, Στέφανος Κωφόπουλος
Hi Silvano,

I have more information regarding this particular issue. 

a) The typical delay is, indeed, a few seconds long, so it is negligible for the purposes of our app.

b) In the evenings, typically after 00:00 (GMT+2), when the day changes, there seems to be a huge delay in the incorporation of the new day's data into the reporting mechanism. In the attached screenshot, which was taken at 00:44 on the 15th, there is no data at all; the day isn't even included in the report, despite the fact that it is within the selected range.
 

My last check was performed at 02:00, and I could see no change. Also, at the Home page, "Today so far" reports the previous day's earnings.

I was wondering whether AdSense is meant to behave in this manner during this time frame, which would mean taking this into account in a future version of our app, or if this is a bug.

Thank you,

Nick

--
Nick Toumpelis
iOS Software Engineer
nickto...@me.com
@nicktoumpelis

Silvano Luciani

unread,
Feb 15, 2012, 7:21:29 AM2/15/12
to AdSense API Forum
Hello Nick,

we support AdSense APIs issues in this forum, but yours seems an
AdSense Frontend problem, so you need to contact the AdSense support:
https://support.google.com/adsense/bin/answer.py?hl=en&answer=9722

I've found this discussion in the AdSense Help forum that is about the
same issue that you are reporting:
http://www.google.com/support/forum/p/AdSense/thread?tid=5240cdee339fcb6d&hl=en

Hope that can help!

Cheers,
Silvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

On Feb 15, 11:19 am, Nick Toumpelis <nicktoumpe...@gmail.com> wrote:
> Hi Silvano,
>
> I have more information regarding this particular issue.
>
> a) The typical delay is, indeed, a few seconds long, so it is negligible for the purposes of our app.
>
> b) In the evenings, typically after 00:00 (GMT+2), when the day changes, there seems to be a huge delay in the incorporation of the new day's data into the reporting mechanism. In the attached screenshot, which was taken at 00:44 on the 15th, there is no data at all; the day isn't even included in the report, despite the fact that it is within the selected range.
>
> My last check was performed at 02:00, and I could see no change. Also, at the Home page, "Today so far" reports the previous day's earnings.
>
> I was wondering whether AdSense is meant to behave in this manner during this time frame, which would mean taking this into account in a future version of our app, or if this is a bug.
>
> Thank you,
>
> Nick
>
> --
> Nick Toumpelis
> iOS Software Engineer
> nicktoumpe...@me.com

Nick Toumpelis

unread,
Feb 15, 2012, 7:32:33 AM2/15/12
to adsen...@googlegroups.com
Hi Silvano,

it was happening in the API as well; I just thought that taking the values shown at the console, would be the best way to illustrate this. From the forum, I gather that it happens from time to time, but gets fixed soon after. No more worries for me then. :)

Cheers and thanks for your help,

Nick

--
Nick Toumpelis
iOS Software Engineer

nickto...@me.com
@nicktoumpelis

Max Glaser

unread,
Feb 15, 2012, 8:35:31 AM2/15/12
to AdSense API Forum
Hello Silvano,

Ops, I overlooked Chirag´s suggestion. How can I "wipe out the cache"?
Is there an API command for that?

Regards,
Max Glaser

Silvano Luciani

unread,
Feb 15, 2012, 8:57:37 AM2/15/12
to AdSense API Forum
Hello Max,

I'm sorry but there is no API command for that, you'll need to
manually delete the content of the ioFileCache directory, which is
usually '/tmp/ApiClient'.

The directory is set in the configuration file here:
http://code.google.com/p/google-api-php-client/source/browse/trunk/src/config.php#57

Cheers,
Silvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

Max Glaser

unread,
Feb 15, 2012, 9:29:01 AM2/15/12
to AdSense API Forum
Hello Silvano,

Thank You for the reply! Now, finally we found origin of the
problem :-) You should document this on the report class description,
specially for the today´s values. The older values can be cached,
because they are the same.

Is there a way to disable the ioFile cache? A configuration flag or a
code change on the API source code?

Regards,
Max Glaser


On Feb 15, 9:57 am, Silvano Luciani <silvano.luci...@google.com>
wrote:
> Hello Max,
>
> I'm sorry but there is no API command for that, you'll need to
> manually delete the content of the ioFileCache directory, which is
> usually '/tmp/ApiClient'.
>
> The directory is set in the configuration file here:http://code.google.com/p/google-api-php-client/source/browse/trunk/sr...

Silvano Luciani

unread,
Feb 15, 2012, 9:45:01 AM2/15/12
to AdSense API Forum
Hello Max,

this is not documented because it was a bug of the PHP Client Library,
not a feature of the API.

Starting from this revision of the PHP Client Library, you shouldn't
have that problem anymore:
http://code.google.com/p/google-api-php-client/source/detail?r=347

You might have to wipe out the cache if there is already cached
content in the directory when switching to the new revision.

If you still experience the issue after switching to another revision,
please report it in the Google APIs PHP Client Library project:
http://code.google.com/p/google-api-php-client/issues/list

Cheers,
Silvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

Max Glaser

unread,
Feb 15, 2012, 9:54:21 AM2/15/12
to AdSense API Forum
Hello Silvano,

OK! We will try the newest revision of the PHP Client Library!

Thank You an cheers,
Max Glaser

Nick Toumpelis

unread,
Feb 18, 2012, 4:37:34 AM2/18/12
to adsen...@googlegroups.com
Hi Silvano,

it seems that the "midnight" issue regarding the day change is still there. Some of our customers are reporting delays several hours long.


Thanks,

Nick

Silvano Luciani

unread,
Feb 20, 2012, 5:57:29 AM2/20/12
to AdSense API Forum
Hello Nick,

if the API returns the same data shown in the AdSense website, the
origin of the problem is there and you will need to contact the
AdSense support:
http://support.google.com/adsense/bin/answer.py?hl=en&answer=9722&topic=1316025&ctx=topic

If it's an API problem, meaning that there is a discrepancy between
the data shown in the AdSense website and the data returned by the
API, let me know and I will contact you in private to gather the data
that will allow me to perform some check.

Cheers,
Silvano

--
Silvano Luciani | Developer Programs Engineer

Google UK Limited
Registered Office: Belgrave House, 76 Buckingham Palace Road, London
SW1W 9TQ
Registered in England Number: 3977902

Nick Toumpelis

unread,
Feb 20, 2012, 5:59:35 AM2/20/12
to adsen...@googlegroups.com
OK, thank you Silvano!

--
Nick Toumpelis
iOS Software Engineer

nickto...@me.com
@nicktoumpelis

Reply all
Reply to author
Forward
0 new messages