Adwords api data access

Discussion in 'Google AdWords' started by pacen, May 18, 2010.

  1. #1
    Hello everyone, i come to you because i'm quite desperate ^^. I have two big problems with the api. I'm using php and i can only get the campaigns...

    1) Can someone help me access the groups and the keywords ?

    2) I don't know how to use the sandbox.

    I thank you in advance for your help.

    Here is my code for the campaigns, i hope somebody will help me.
    
    <?php
    
    error_reporting(E_STRICT | E_ALL);
    
    // You can set the include path to src directory or reference
    // AdWordsUser.php directly via require_once.
    // $path = '/path/to/aw_api_php_lib/src';
    $path = dirname(__FILE__) . '/../../src';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    
    require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php';
    
    try {
    // Get AdWordsUser from credentials in "../auth.ini"
    // relative to the AdWordsUser.php file's directory.
    $user = new AdWordsUser();
    
    // Log SOAP XML request and response.
    $user->LogDefaults();
    
    // Get the CampaignService.
    $campaignService = $user->GetCampaignService();
    
    // Get all campaigns.
    $campaignPage = $campaignService->get(new CampaignSelector());
    
    // Display campaigns.
    if (isset($campaignPage->entries))
    {
    foreach ($campaignPage->entries as $campaign)
    {
    print 'Campaign with name "' . $campaign->name . '" and id
    "'
    . $campaign->id . "\" was found.<br/>";
    
    }
    }
    else
    {
    print "No campaigns found.\n";
    }
    
    } catch (Exception $e) {
    print_r($e);
    }
    
    ?> 
    Code (markup):

     
    pacen, May 18, 2010 IP