Hi Pete, Thanks for your help. However, I still can't get anything even though I have set up the predicates. Here are my codes :
<?php /** * This example gets and downloads a report from a report definition. * To get a report definition, run AddKeywordsPerformanceReportDefinition.php. * Currently, there is only production support for report download. * * PHP version 5 * * Copyright 2011, Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @package GoogleApiAdsAdWords * @subpackage v201101 * @category WebServices * @copyright 2011, Google Inc. All Rights Reserved. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, * Version 2.0 * @author Eric Koleda <[email protected]> */ 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 'vendors/google_adwords/src/Google/Api/Ads/AdWords/Lib/ AdWordsUser.php'; require_once 'vendors/google_adwords/src/Google/Api/Ads/AdWords/Util/ ReportUtils.php'; /** * * First we want to request for a report */ function addKeywordsPerformance($user){ try { // Get AdWordsUser from credentials in "../auth.ini" // relative to the AdWordsUser.php file's directory. $devtoken = $user->GetDeveloperToken(); // Log SOAP XML request and response. $user->LogDefaults(); // Get the GetReportDefinitionService. $reportDefinitionService = $user- >GetReportDefinitionService('v201101'); $startDate = date("Ymd", strtotime("-3 days")); $endDate = date("Ymd", strtotime("-1 days")); // Create selector to indicate which fields we want to get $selector = new Selector(); $selector->fields = array('AdGroupId', 'CampaignId', 'CampaignName', 'CampaignStatus', 'KeywordText', 'TotalConvValue', 'KeywordMatchType', 'Impressions', 'Clicks', 'Cost'); $selector->dateRange = new DateRange($startDate, $endDate); // Create predicates. $adGroupId = 3000250943; $adGroupPredicate = new Predicate(); $adGroupPredicate->field = 'AdGroupId'; $adGroupPredicate->operator = 'EQUALS'; $adGroupPredicate->values = array($adGroupId); $selector->predicates = array($adGroupPredicate); // Create report definition. $reportDefinition = new ReportDefinition(); $reportDefinition->reportName = 'Keywords performance report #' . time(); $reportDefinition->dateRangeType = 'CUSTOM_DATE'; $reportDefinition->reportType = 'KEYWORDS_PERFORMANCE_REPORT'; $reportDefinition->downloadFormat = 'XML'; $reportDefinition->selector = $selector; // Create operations. $operation = new ReportDefinitionOperation(); $operation->operand = $reportDefinition; $operation->operator = 'ADD'; $operations = array($operation); // Add report definition. $result = $reportDefinitionService->mutate($operations); // Display report definitions. if ($result != null) { var_dump($result); print_r($result, true); foreach ($result as $reportDefinition) { printf("Report definition with name '%s' and id '%s' was added.\n", $reportDefinition->reportName, $reportDefinition->id); return $reportDefinition->id; } } else { print "No report definitions were added.\n"; } } catch (Exception $e) { print $e->getMessage(); exit(); } } 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(); $reportDefinitionId = addKeywordsPerformance($user); print("Report definiton id = $reportDefinitionId"); $fileName = 'google_adword.xml'; $path = dirname(__FILE__) . '/' . $fileName; // Download report. ReportUtils::DownloadReport($reportDefinitionId, $path, $user); printf("Report with definition id '%s' was downloaded to '%s'.\n", $reportDefinitionId, $fileName); } catch (Exception $e) { print $e->getMessage(); } Thanks On Apr 24, 8:35 pm, "Pete Lavetsky (AdWords API Guru)" <[email protected]> wrote: > Take a look at the Predicate > section:http://code.google.com/p/google-api-adwords-java/source/browse/trunk/... > > Pete > > On Apr 22, 1:47 pm, herbertbintoroe <[email protected]> wrote: > > > Hi all, > > > I am trying to download keyword performance report and basically use > > the latest version of the api(201101) to create > > keyword_performance_report and using DownloadReport to download the > > report (using the codes from the examples folder). > > > I was able to download the report, but I could only see the headers of > > the columns that I specified, with no data in there. > > Can somebody help me on how to get the data? > > > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en
