Get current CTR ?

185 views
Skip to first unread message

Auden69

unread,
Dec 1, 2011, 3:22:44 PM12/1/11
to adsen...@googlegroups.com
Hello,

I have to check my current CTR from my adsense account many times per days.. In the past, I used this script (http://code.google.com/p/php-adsense-account-library/) but it doesn't work anymore since 2 month...

Is this API would help me to get my current CTR ?

Thanks.

Silvano Luciani

unread,
Dec 2, 2011, 5:24:18 AM12/2/11
to AdSense API Forum
Hello there,

you can use the AdSense Management API to obtain reports on your
account's performance, according to your criteria.

This is the home page for the documentation:
http://code.google.com/apis/adsense/management/index.html

And this is the documentation for the function that generates the
reports, where you can find the list of metrics that you can include
in your reports:
http://code.google.com/apis/adsense/management/v1/reference.html#method_adsense_reports_generate

If you want to experiment with the API you can use the Google APIs
Explorer:
https://code.google.com/apis/explorer/

Remember to click "Switch to Private Access" to authenticate with
Google using OAuth 2, otherwise you won't be able to read any data.

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

Auden69

unread,
Dec 3, 2011, 10:25:06 AM12/3/11
to adsen...@googlegroups.com
Thanks for your support.. but i've some difficulty with POO et and I never use a API :-(

I found the request I need with this this tool =>
https://code.google.com/apis/explorer/

What I need :
GET https://www.googleapis.com/adsense/v1/reports?startDate=2011-12-02&endDate=2011-12-02&metric=PAGE_VIEWS_CTR&fields=totals&pp=1&key={YOUR_API_KEY}

I'ts ok in the explorer but out ot the exploreer, i need to be authenficated before launch my request... and i don't know how to do :-(
This is my problem :


"error": {
"errors": [
{
"domain": "global",
"reason": "required",
"message": "Login Required",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Login Required"
}
}

As you can see English is not my native language....  My goal is to get my CTR with a Php script....
There is a french suppport ?

Thanks

Silvano Luciani

unread,
Dec 3, 2011, 12:27:46 PM12/3/11
to AdSense API Forum
Hello,

I'm sorry but we provide support in english only, but don't worry, I
understand your question!

We have this article that explains how to do authentication with Java,
Python and PHP using the Google API's client libraries:
http://adsenseapi.blogspot.com/2011/11/adsense-management-api-oauth-20-for-web.html

If you want to write a script intended to be executed from a shell,
I'd suggest you to use Python instead, because the Python client
library supports the OAuth 2.0 authentication flow for native
applications.

You can find guides to use the AdSense Management API with the Google
APIs client libraries for Java, Python and PHP here:
http://code.google.com/apis/adsense/management/v1/complete_guide.html

If you'd rather do it in PHP, the Client library includes an example
of PHP web application:
http://code.google.com/p/google-api-php-client/source/browse/#svn%2Ftrunk%2Fexamples%2Fadsense


Don't hesitate to post if you have any additional questions!

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 Dec 3, 3:25 pm, Auden69 <Aude...@gmail.com> wrote:
> Thanks for your support.. but i've some difficulty with POO et and I never
> use a API :-(
>
> I found the request I need with this this tool =>https://code.google.com/apis/explorer/
>
> What I need :

> GEThttps://www.googleapis.com/adsense/v1/reports?startDate=2011-12-02&en...{YOUR_API_KEY}

Silvano Luciani

unread,
Dec 3, 2011, 12:40:44 PM12/3/11
to AdSense API Forum
Hello again,

in my previous reply I forgot this other resource, a blog post on the
OAuth 2.0 authentication flow for native applications in Java or
Python:
http://adsenseapi.blogspot.com/2011/11/adsense-management-api-oauth-20-for.html

It's the authentication flow to use for installed applications.

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 Dec 3, 5:27 pm, Silvano Luciani <silvano.luci...@google.com> wrote:
> Hello,
>
> I'm sorry but we provide support in english only, but don't worry, I
> understand your question!
>
> We have this article that explains how to do authentication with Java,

> Python and PHP using the Google API's client libraries:http://adsenseapi.blogspot.com/2011/11/adsense-management-api-oauth-2...


>
> If you want to write a script intended to be executed from a shell,
> I'd suggest you to use Python instead, because the Python client
> library supports the OAuth 2.0 authentication flow for native
> applications.
>
> You can find guides to use the AdSense Management API with the Google
> APIs client libraries for Java, Python and PHP here:http://code.google.com/apis/adsense/management/v1/complete_guide.html
>
> If you'd rather do it in PHP, the Client library includes an example

> of PHP web application:http://code.google.com/p/google-api-php-client/source/browse/#svn%2Ft...

Reply all
Reply to author
Forward
0 new messages