How do I retrieve a placement using url?

20 views
Skip to first unread message

Ken Dan Tinio

unread,
Feb 8, 2018, 1:13:26 AM2/8/18
to AdWords API Forum
So far I have this retrieves a placement using Id:

    $campaignCriterionService = $adwords['adWordsServices']->get($adwords['session'], AdGroupCriterionService::class);

    // Create a selector to select all campaign criteria for the specified
    // campaign.
    $selector = new Selector();
    $selector->setFields(['Id', 'AdGroupId', 'CriteriaType', 'KeywordText', 'DisplayName']);
    $selector->setPredicates([
        new Predicate('Id', PredicateOperator::EQUALS, ['412515468868'])
    ]);
    $selector->setPaging(new Paging(0, self::PAGE_LIMIT));

    $totalNumEntries = 0;
    do {
      // Retrieve campaign criteria one page at a time, continuing to request
      // pages until all campaign criteria have been retrieved.
      $page = $campaignCriterionService->get($selector);

      // Print out some information for each campaign criterion.
      if ($page->getEntries() !== null) {
        $totalNumEntries = $page->getTotalNumEntries();
        foreach ($page->getEntries() as $campaignCriterion) {
          $data[] = array(
              "id"   => $campaignCriterion->getCriterion()->getId(),
              "type" => $campaignCriterion->getCriterion()->getType()
          );
        }
      }

      $selector->getPaging()->setStartIndex(
          $selector->getPaging()->getStartIndex() + self::PAGE_LIMIT);
    } while ($selector->getPaging()->getStartIndex() < $totalNumEntries);

    $message = "Number of results found: ".$totalNumEntries;
    return array(
      "status"  => "success",
      "message" => $message,
      "data"    => $data
    );

I do not know which field is it used.

WHat I want to do: 

Select placement where url is equals to 'example.com'



Peter Oliquino

unread,
Feb 8, 2018, 3:17:20 AM2/8/18
to AdWords API Forum
Hi Ken,

You can try adding the "PlacementUrl" field as a predicate. For additonal reference, you may check out this guide for the various selectable/filterable fields of AdWords services and objects. Let me know if this helps.

Best regards,
Peter
AdWords API Team

Ken Dan Tinio

unread,
Feb 8, 2018, 3:39:37 AM2/8/18
to AdWords API Forum
I already figured that out. Thanks for answering! 
Reply all
Reply to author
Forward
0 new messages