examples/AdWords/v201809/Extensions/AddSitelinksUsingFeeds.php
private static function restrictFeedItemToGeoTarget(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        FeedItem $feedItem,
        $locationId
    ) {
        $feedItemTargetService = $adWordsServices->get(
            $session,
            FeedItemTargetService::class
        );

        // Optional: Restrict the feed item to only serve with ads for the
        // specified geo target.
        $feedItemCriterionTarget = new FeedItemCriterionTarget();
        $feedItemCriterionTarget->setFeedId($feedItem->getFeedId());
        $feedItemCriterionTarget->setFeedItemId($feedItem->getFeedItemId());

        $location = new Location();
        // The IDs can be found in the documentation or retrieved with the
        // LocationCriterionService.
        $location->setId($locationId);
        $feedItemCriterionTarget->setCriterion($location);

        // Create a feed item target operation.
        $operation = new FeedItemTargetOperation();
        $operation->setOperand($feedItemCriterionTarget);
        $operation->setOperator(Operator::ADD);

        // Create the feed item target on the server and print out
        // some information.
        $result = $feedItemTargetService->mutate([$operation]);
        $feedItemCriterionTarget = $result->getValue()[0];
        printf(
            'Feed item target for feed ID %d and feed item ID %d was '
            . 'created to restrict serving to location ID %d.%s',
            $feedItemCriterionTarget->getFeedId(),
            $feedItemCriterionTarget->getFeedItemId(),
            $feedItemCriterionTarget->getCriterion()->getId(),
            PHP_EOL
        );
    }
private static function restrictFeedItemToGeoTarget(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        FeedItem $feedItem,
        $locationId
    ) {
        $feedItemTargetService = $adWordsServices->get(
            $session,
            FeedItemTargetService::class
        );

        // Optional: Restrict the feed item to only serve with ads for the
        // specified geo target.
        $feedItemCriterionTarget = new FeedItemCriterionTarget();
        $feedItemCriterionTarget->setFeedId($feedItem->getFeedId());
        $feedItemCriterionTarget->setFeedItemId($feedItem->getFeedItemId());

        $location = new Location();
        // The IDs can be found in the documentation or retrieved with the
        // LocationCriterionService.
        $location->setId($locationId);
        $feedItemCriterionTarget->setCriterion($location);

        // Create a feed item target operation.
        $operation = new FeedItemTargetOperation();
        $operation->setOperand($feedItemCriterionTarget);
        $operation->setOperator(Operator::ADD);

        // Create the feed item target on the server and print out
        // some information.
        $result = $feedItemTargetService->mutate([$operation]);
        $feedItemCriterionTarget = $result->getValue()[0];
        printf(
            'Feed item target for feed ID %d and feed item ID %d was '
            . 'created to restrict serving to location ID %d.%s',
            $feedItemCriterionTarget->getFeedId(),
            $feedItemCriterionTarget->getFeedItemId(),
            $feedItemCriterionTarget->getCriterion()->getId(),
            PHP_EOL
        );
    }
private static function restrictFeedItemToGeoTarget ( AdWordsServices $ adWordsServices , AdWordsSession $ session , FeedItem $ feedItem , $ locationId ) { $ feedItemTargetService = $ adWordsServices -> get ( $ session , FeedItemTargetService :: class ) ; // Optional: Restrict the feed item to only serve with ads for the // specified geo target. $ feedItemCriterionTarget = new FeedItemCriterionTarget ( ) ; $ feedItemCriterionTarget -> setFeedId ( $ feedItem -> getFeedId ( ) ) ; $ feedItemCriterionTarget -> setFeedItemId ( $ feedItem -> getFeedItemId ( ) ) ; $ location = new Location ( ) ; // The IDs can be found in the documentation or retrieved with the // LocationCriterionService. $ location -> setId ( $ locationId ) ; $ feedItemCriterionTarget -> setCriterion ( $ location ) ; // Create a feed item target operation. $ operation = new FeedItemTargetOperation ( ) ; $ operation -> setOperand ( $ feedItemCriterionTarget ) ; $ operation -> setOperator ( Operator :: ADD ) ; // Create the feed item target on the server and print out // some information. $ result = $ feedItemTargetService -> mutate ( [ $ operation ] ) ; $ feedItemCriterionTarget = $ result -> getValue ( ) [ 0 ] ; printf ( 'Feed item target for feed ID %d and feed item ID %d was ' . 'created to restrict serving to location ID %d.%s' , $ feedItemCriterionTarget -> getFeedId ( ) , $ feedItemCriterionTarget -> getFeedItemId ( ) , $ feedItemCriterionTarget -> getCriterion ( ) -> getId ( ) , PHP_EOL ) ; }
Restricts the first feed item to only serve with ads for the specified
location ID.

@param AdWordsServices $adWordsServices the AdWords services
@param AdWordsSession $session the AdWords session
@param FeedItem $feedItem the feed item to restrict
@param int $locationId the location ID to which the feed item will be
restricted
Restricts the first feed item to only serve with ads for the specified location ID .