Hello, I am new to the AdWords API and I am trying to understand how to use the different services. I am having problems with the TrafficEstimatorService as there is no example in the current version of the PHP API. When I try to use the previous version API I get some error with the class "CountryTarget()" that does not exists in the current version.
This is the code I am testing: $path = dirname(__FILE__) . '/../../../src'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); require_once 'Google/Api/Ads/AdWords/Lib/AdWordsUser.php'; require_once 'Google/Api/Ads/Common/Util/MapUtils.php'; // Constants used in the example. define('PAGE_SIZE', 500); /** * Runs the example. * @param AdWordsUser $user the user to run the example with */ function GetKeywordIdeasExample(AdWordsUser $user) { // Get the service, which loads the required classes. $targetingIdeaService = $user->GetService('TrafficEstimatorService', 'v201109'); $keywords = array(); $keywords[] = new Keyword('mars cruise', 'BROAD'); $keywords[] = new Keyword('cheap cruise', 'PHRASE'); $keywords[] = new Keyword('cruise', 'EXACT'); // Create a keyword estimate request for each keyword. $keywordEstimateRequests = array(); foreach ($keywords as $keyword) { $keywordEstimateRequest = new KeywordEstimateRequest(); $keywordEstimateRequest->keyword = $keyword; $keywordEstimateRequests[] = $keywordEstimateRequest; } // Create ad group estimate requests. $adGroupEstimateRequest = new AdGroupEstimateRequest(); $adGroupEstimateRequest->keywordEstimateRequests = $keywordEstimateRequests; $adGroupEstimateRequest->maxCpc = new Money(1000000); $adGroupEstimateRequests = array($adGroupEstimateRequest); // Create campaign estimate requests. $campaignEstimateRequest = new CampaignEstimateRequest(); $campaignEstimateRequest->adGroupEstimateRequests = $adGroupEstimateRequests; $campaignEstimateRequest->targets = array(new CountryTarget('US'), new LanguageTarget('en')); $campaignEstimateRequests = array($campaignEstimateRequest); // Create selector. $selector = new TrafficEstimatorSelector(); $selector->campaignEstimateRequests = $campaignEstimateRequests; // Get traffic estimates. $result = $trafficEstimatorService->get($selector); // Display traffic estimates. if (isset($result)) { $keywordEstimates = $result->campaignEstimates[0]->adGroupEstimates[0]- >keywordEstimates; for ($i = 0; $i < sizeof($keywordEstimates); $i++) { $keyword = $keywordEstimateRequests[$i]->keyword; $keywordEstimate = $keywordEstimates[$i]; // Find the mean of the min and max values. $meanAverageCpc = ($keywordEstimate->min->averageCpc- >microAmount + $keywordEstimate->max->averageCpc->microAmount) / 2; $meanAveragePosition = ($keywordEstimate->min->averagePosition + $keywordEstimate->max->averagePosition) / 2; $meanClicks = ($keywordEstimate->min->clicks + $keywordEstimate->max->clicks) / 2; $meanTotalCost = ($keywordEstimate->min->totalCost->microAmount + $keywordEstimate->max->totalCost->microAmount) / 2; printf("Results for the keyword with text '%s' and match type '%s':\n", $keyword->text, $keyword->matchType); printf(" Estimated average CPC: %.0f\n", $meanAverageCpc); printf(" Estimated ad position: %.2f \n", $meanAveragePosition); printf(" Estimated daily clicks: %d\n", $meanClicks); printf(" Estimated daily cost: %.0f\n\n", $meanTotalCost); } } else { print "No traffic estimates were returned.\n"; } } try { // Get AdWordsUser from credentials in "../auth.ini" // relative to the AdWordsUser.php file's directory. $user = new AdWordsUser(); // Log every SOAP XML request and response. $user->LogAll(); // Run the example. GetKeywordIdeasExample($user); } catch (Exception $e) { printf("An error has occurred: %s\n", $e->getMessage()); } The error is on line 72, but remember thats an example from a previous version of the API. Any tip in the right direction will be much appreciated! Thanks! -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.blogspot.com http://groups.google.com/group/adwords-api =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To post to this group, send email to adwords-api@googlegroups.com To unsubscribe from this group, send email to adwords-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en