Hello, I have been completely unable to use the api to access reporting stats. I am still relatively new to programming and solving this has become incredibly frustrating. I have been at this for quite some time and am hoping someone from Google or this forum can PLEASE help me out. I am trying to simple retrieve campaign stats for our MCC account to insert into a MySQL database. I am using an example, but have yet to successfully make this work. I hope this is a simple mistake I am doing that is a fast resolution. When I run the code below, it returns NOTHING, a blank screen...? Somebody please help me!
<?php require_once 'Api/Ads/AdWords/Lib/AdWordsUser.php'; require_once 'Api/Ads/AdWords/Util/ReportUtils.php'; function GetCampaignStatsExample(AdWordsUser $user) { // Get the service, which loads the required classes. $campaignService = $user->GetService('CampaignService', ADWORDS_VERSION); // Create selector. $selector = new Selector(); $selector->fields = array('Id', 'Name', 'Impressions', 'Clicks', 'Cost', 'Ctr'); $selector->predicates[] = new Predicate('Impressions', 'GREATER_THAN', array(0)); // Set date range to request stats for. $dateRange = new DateRange(); $dateRange->min = date('Ymd', strtotime('-1 week')); $dateRange->max = date('Ymd', strtotime('-1 day')); $selector->dateRange = $dateRange; // Create paging controls. $selector->paging = new Paging(0, AdWordsConstants::RECOMMENDED_PAGE_SIZE); do { // Make the get request. $page = $campaignService->get($selector); // Display results. if (isset($page->entries)) { foreach ($page->entries as $campaign) { printf("Campaign with name '%s' and id '%s' had the following stats " . "during the last week:\n", $campaign->name, $campaign->id); printf(" Impressions: %d\n", $campaign->campaignStats->impressions); printf(" Clicks: %d\n", $campaign->campaignStats->clicks); printf(" Cost: $%.2f\n", $campaign->campaignStats->cost->microAmount / AdWordsConstants::MICROS_PER_DOLLAR); printf(" CTR: %.2f%%\n", $campaign->campaignStats->ctr * 100); } } else { print "No matching campaigns were found.\n"; } // Advance the paging index. $selector->paging->startIndex += AdWordsConstants::RECOMMENDED_PAGE_SIZE; } while ($page->totalNumEntries > $selector->paging->startIndex); } // Don't run the example if the file is being included. if (__FILE__ != realpath($_SERVER['PHP_SELF'])) { return; } 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. GetCampaignStatsExample($user); } catch (OAuth2Exception $e) { ExampleUtils::CheckForOAuth2Errors($e); } catch (ValidationException $e) { ExampleUtils::CheckForOAuth2Errors($e); } catch (Exception $e) { printf("An error has occurred: %s\n", $e->getMessage()); } ?> -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://googleadsdeveloper.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 --- You received this message because you are subscribed to the Google Groups "AdWords API Forum" group. To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.