Friday, April 5, 2013

Digest for - 1 Message in 1 Topic


    Renato Valencia <> Apr 03 12:33PM -0700  

    Hello guys hope someone can help me.
    So I manage to authenticate using the examples of the client library and by
    my own script and both are giving me empty results.
    But when I use the google site "try it
    It does give me some results.
    Tnx a lot!
    * Some screenshots attached and my own script code here:
    require_once 'src/Google_Client.php';
    require_once 'src/contrib/Google_AdsenseService.php';
    $client = new Google_Client();
    $client -> setApplicationName('Ad Sense Revenue');
    $client -> setClientId('#clientid');
    $client -> setClientSecret('#clientsecret');
    $client -> setRedirectUri('http://localhost/test/index.php');
    $client -> setDeveloperKey('#apikey');
    $client -> setScopes('');
    $service = new Google_AdSenseService($client);
    if (isset($_GET['logout'])) { // logout: destroy token
    die('Logged out.');
    if (isset($_GET['code'])) { // we received the positive auth callback, get
    the token and store it in session
    $_SESSION['token'] = $client->getAccessToken();
    if (isset($_SESSION['token'])) { // extract token from session and
    configure client
    $token = $_SESSION['token'];
    if (!$client->getAccessToken()) { // auth call to google
    $authUrl = $client->createAuthUrl();
    header("Location: ".$authUrl);
    try {
    $optParams = array('metric' => array('earnings'), 'dimension' => 'date');
    $data = $service -> reports -> generate('2013-01-01', '2013-03-03',
    echo '<pre>' . print_r($data, TRUE) . '</pre>';
    } catch(Exception $e) {
    echo '<pre>', print_r($e, TRUE) . '</pre>';


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 unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

1 comment:

  1. Helping optimistic people excel - in 7 areas of life is her mission.
    You have to find a way to take the tips you learn and make maximum use of
    them. Remember; there is a difference between a fattening diet and a healthy diet.

    Feel free to visit my blog post fitness tips and workouts