Adwords API php limit query

48 views
Skip to first unread message

Andrada Crisan

unread,
Aug 14, 2015, 12:10:18 PM8/14/15
to AdWords API Forum

Hello,

 I am interested to get the first 10 keywords in querying google adwords api.
How must be defined the selector in php to display this result?

Example code:

//start code

function InsertKeywordsIntoDBTypePlacement(AdWordsUser $user) {
  // Get the service, which loads the required classes.
  $adGroupCriterionService = $user->GetService('AdGroupCriterionService', ADWORDS_VERSION);
  
  $adwaccid = getAdWId($user);

  // Create selector.
  $selector = new Selector();
  $selector->fields = array('KeywordText', 'KeywordMatchType', 'Id', 'ActiveViewCpmEnabled', 'AdGroupId', 'AgeRangeType',
          'AppPaymentModelType', 'ApprovalStatus', 'BidModifier', 'BidType', 'BiddingStrategyId', 'BiddingStrategyName',
          'BiddingStrategySource', 'BiddingStrategyType', 'CaseValue', 'ChannelId', 'ChannelName', 'CpcBid', 'CpcBidSource',
          'CpmBid', 'CpmBidSource', 'CriteriaCoverage', 'CriteriaSamples', 'CriteriaType', 'CriterionUse', 'DestinationUrl', 
          'DisapprovalReasons', 'DisplayName', 'EnhancedCpcEnabled', 'ExperimentBidMultiplier',
          'ExperimentDataStatus', 'ExperimentDeltaStatus', 'ExperimentId', 'FinalAppUrls', 'FinalMobileUrls', 'FinalUrls',
          'FirstPageCpc', 'GenderType', 'IsKeywordAdRelevanceAcceptable', 'IsLandingPageQualityAcceptable', 'Labels',
          'MobileAppCategoryId', 'Parameter', 'ParentCriterionId', 'PartitionType', 'Path', 'PlacementUrl', 'QualityScore', 
          'Status', 'SystemServingStatus', 'TopOfPageCpc', 'TrackingUrlTemplate', 'UrlCustomParameters', 'UserInterestId',
          'UserInterestName', 'UserListId', 'UserListMembershipStatus', 'UserListName', 'VerticalId', 'VerticalParentId', 'VideoId', 'VideoName' );
  
  $selector->ordering[] = new OrderBy('KeywordText', 'ASCENDING');

  // Create predicates.
  //$selector->predicates[] = new Predicate('AdGroupId', 'IN', array($adGroupId));
  $selector->predicates[] =
      new Predicate('CriteriaType', 'IN', array('PLACEMENT'));


//!!!!!HERE>>>>>  it is not correct .....???? how to do this?
 $selector->limit[] = new withLimit('10');
//<<<<<<
  
  $keywordselection = $adGroupCriterionService->get($selector);

etc....

}

//end code



Thank you!

Anthony Madrigal

unread,
Aug 14, 2015, 2:03:44 PM8/14/15
to AdWords API Forum
Hello Andrada,

In the GetKeywords example, you will see that there is a variable called Paging. The fields to be set are the starting index and how many results you want to be returned.

Cheers,
Anthony
AdWords API Team
Reply all
Reply to author
Forward
0 new messages