Thursday, March 1, 2012

Digest for adsense-api@googlegroups.com - 2 Messages in 1 Topic

Group: http://groups.google.com/group/adsense-api/topics

    "Raúl Mellado" <raulmellado@gmail.com> Feb 28 10:52PM -0800  

    Hi everybody (specially to Silvano who kindly answers all of our
    questions),
     
    I am trying to develop a Wordpress plugin (in PHP) that will show, in
    the backend, earnings for a current blog (filtering per custom channels)
    using Management API. I am very new to Google Apis and OAuth, so I am a bit
    lost :-)
     
    The first thing I did was to download the package api-php-client
    (current version 0.4.9) from
    http://code.google.com/p/google-api-php-client/downloads/list.
     
    I first tried the tasks example and made it work, creating a project in
    Google APIs section, well done for me! :-)
     
    Now I tried the Adsense example; I created a new project in the Google
    APIs, updated the example php code with my data (first difference I noticed
    was that there is this additional
    code: $this->apiClient->setDeveloperKey('YOUR_DEVELOPER_KEY_HERE');, could
    you add some light on where I can get my developer key?).
     
    When I upload the code to my server and
    load /examples/adsense/index.php, I get the message:
     
    *Fatal error*: Call to a member function execute() on a non-object in *
    /public_html/gapis/examples/adsense/AdSenseAuth.php* on line *131*
     
    Now I check this problem, and it comes from here:
     
    public function authenticate($user) {
    $this->user = $user;
    $dbh = new PDO('sqlite:examples.sqlite');
    var_dump($dbh); //added by me
     
    For some reason, $dbh object is empty (added the var_dump myself to
    test).
     
    Do you have any idea about what could be happening here?
     
     
    And my second question here (well, this is for later on, when I can make
    the example code work), is this: as I would like each user to install this
    wp plugin in their own self-hosted WordPress installation, I have seen that
    I need to enter a redirect uri/JavaScript origin. Does this mean each user
    needs to add a new url for each blog they have? Or is there a better way to
    do this, to make it domain independent and make it easier for the user to
    install? (and last question for now -promised!- could I use the "offline"
    mode to gather data in a passive mode while the user is not logged in?).
     
    Thanks for your patience answering my newbie questions!
     
     
    Raul

     

    Silvano Luciani <silvano.luciani@google.com> Feb 29 02:15AM -0800  

    Hello Raul,
     
    thanks :D
     
    You can find the DeveloperKey in the Google API Console, in the tab
    'API Access':
    https://code.google.com/apis/console/
     
    At the end of the API Access page there is a box named Simple API
    Access, API key is what you are looking for.
    The DeveloperKey is meant to be used for request that need to be
    signed but don't need authorization; for the AdSense Management API,
    every request needs to be authorized, so the Key is not enough to send
    requests.
     
    About the error, you need to create the database 'example.sqlite',
    looks like you didn't, the docs of the class 'AdSenseAuth' explain
    what you need to do:
    http://code.google.com/p/google-api-php-client/source/browse/trunk/examples/adsense/AdSenseAuth.php#29
     
    The answer for the redirect URI question is yes, every user will have
    to create a project in the Google API Console, create a client id for
    web application, set their redirect URI and Javascript Origins.
     
    Last reply: yes, the offline access is meant exactly for that use
    case. If you use the Google API PHP Client Library, is enabled by
    default:
    http://code.google.com/p/google-api-php-client/source/browse/trunk/src/auth/apiOAuth2.php#36
     
    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
     

     

You received this message because you are subscribed to the Google Group adsense-api.
You can post via email.
To unsubscribe from this group, send an empty message.
For more options, visit this group.

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

No comments:

Post a Comment