examples/AdWords/v201809/Extensions/AddSitelinksUsingFeeds.php
private static function createSitelinksFeedItems(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        array $sitelinksData
    ) {
        $feedItemService =
            $adWordsServices->get($session, FeedItemService::class);

        // Create operations to add feed items.
        $home = self::newSitelinkFeedItemAddOperation(
            $sitelinksData,
            'Home',
            'http://www.example.com',
            'Home line 2',
            'Home line 3'
        );
        $stores = self::newSitelinkFeedItemAddOperation(
            $sitelinksData,
            'Stores',
            'http://www.example.com/stores',
            'Stores line 2',
            'Stores line 3'
        );
        $onSale = self::newSitelinkFeedItemAddOperation(
            $sitelinksData,
            'On Sale',
            'http://www.example.com/sale',
            'On Sale line 2',
            'On Sale line 3'
        );
        $support = self::newSitelinkFeedItemAddOperation(
            $sitelinksData,
            'Support',
            'http://www.example.com/support',
            'Support line 2',
            'Support line 3'
        );
        $products = self::newSitelinkFeedItemAddOperation(
            $sitelinksData,
            'Products',
            'http://www.example.com/products',
            'Products line 2',
            'Products line 3'
        );
        // This site link is using geographical targeting to use
        // LOCATION_OF_PRESENCE.
        $aboutUs = self::newSitelinkFeedItemAddOperation(
            $sitelinksData,
            'About Us',
            'http://www.example.com/about',
            'About Us line 2',
            'About Us line 3',
            true
        );

        // Add feed item operations on the server and print out some information.
        $result = $feedItemService->mutate(
            [$home, $stores, $onSale, $support, $products, $aboutUs]
        );
        $sitelinksData['sitelinkFeedItemIds'] = [];

        foreach ($result->getValue() as $feedItem) {
            printf(
                'Feed item with feed item ID %d was added.%s',
                $feedItem->getFeedItemId(),
                PHP_EOL
            );
            $sitelinksData['sitelinkFeedItemIds'][] =
                $feedItem->getFeedItemId();
        }

        // Target the "aboutUs" sitelink to geographically target California.
        // See https://developers.google.com/adwords/api/docs/appendix/geotargeting
        // for location criteria of supported locations.
        self::restrictFeedItemToGeoTarget(
            $adWordsServices,
            $session,
            $result->getValue()[5],
            21137
        );

        return $sitelinksData;
    }
private static function createSitelinksFeedItems(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        array $sitelinksData
    ) {
        $feedItemService =
            $adWordsServices->get($session, FeedItemService::class);

        // Create operations to add feed items.
        $home = self::newSitelinkFeedItemAddOperation(
            $sitelinksData,
            'Home',
            'http://www.example.com',
            'Home line 2',
            'Home line 3'
        );
        $stores = self::newSitelinkFeedItemAddOperation(
            $sitelinksData,
            'Stores',
            'http://www.example.com/stores',
            'Stores line 2',
            'Stores line 3'
        );
        $onSale = self::newSitelinkFeedItemAddOperation(
            $sitelinksData,
            'On Sale',
            'http://www.example.com/sale',
            'On Sale line 2',
            'On Sale line 3'
        );
        $support = self::newSitelinkFeedItemAddOperation(
            $sitelinksData,
            'Support',
            'http://www.example.com/support',
            'Support line 2',
            'Support line 3'
        );
        $products = self::newSitelinkFeedItemAddOperation(
            $sitelinksData,
            'Products',
            'http://www.example.com/products',
            'Products line 2',
            'Products line 3'
        );
        // This site link is using geographical targeting to use
        // LOCATION_OF_PRESENCE.
        $aboutUs = self::newSitelinkFeedItemAddOperation(
            $sitelinksData,
            'About Us',
            'http://www.example.com/about',
            'About Us line 2',
            'About Us line 3',
            true
        );

        // Add feed item operations on the server and print out some information.
        $result = $feedItemService->mutate(
            [$home, $stores, $onSale, $support, $products, $aboutUs]
        );
        $sitelinksData['sitelinkFeedItemIds'] = [];

        foreach ($result->getValue() as $feedItem) {
            printf(
                'Feed item with feed item ID %d was added.%s',
                $feedItem->getFeedItemId(),
                PHP_EOL
            );
            $sitelinksData['sitelinkFeedItemIds'][] =
                $feedItem->getFeedItemId();
        }

        // Target the "aboutUs" sitelink to geographically target California.
        // See https://developers.google.com/adwords/api/docs/appendix/geotargeting
        // for location criteria of supported locations.
        self::restrictFeedItemToGeoTarget(
            $adWordsServices,
            $session,
            $result->getValue()[5],
            21137
        );

        return $sitelinksData;
    }
private static function createSitelinksFeedItems ( AdWordsServices $ adWordsServices , AdWordsSession $ session , array $ sitelinksData ) { $ feedItemService = $ adWordsServices -> get ( $ session , FeedItemService :: class ) ; // Create operations to add feed items. $ home = self :: newSitelinkFeedItemAddOperation ( $ sitelinksData , 'Home' , 'http://www.example.com' , 'Home line 2' , 'Home line 3' ) ; $ stores = self :: newSitelinkFeedItemAddOperation ( $ sitelinksData , 'Stores' , 'http://www.example.com/stores' , 'Stores line 2' , 'Stores line 3' ) ; $ onSale = self :: newSitelinkFeedItemAddOperation ( $ sitelinksData , 'On Sale' , 'http://www.example.com/sale' , 'On Sale line 2' , 'On Sale line 3' ) ; $ support = self :: newSitelinkFeedItemAddOperation ( $ sitelinksData , 'Support' , 'http://www.example.com/support' , 'Support line 2' , 'Support line 3' ) ; $ products = self :: newSitelinkFeedItemAddOperation ( $ sitelinksData , 'Products' , 'http://www.example.com/products' , 'Products line 2' , 'Products line 3' ) ; // This site link is using geographical targeting to use // LOCATION_OF_PRESENCE. $ aboutUs = self :: newSitelinkFeedItemAddOperation ( $ sitelinksData , 'About Us' , 'http://www.example.com/about' , 'About Us line 2' , 'About Us line 3' , true ) ; // Add feed item operations on the server and print out some information. $ result = $ feedItemService -> mutate ( [ $ home , $ stores , $ onSale , $ support , $ products , $ aboutUs ] ) ; $ sitelinksData [ 'sitelinkFeedItemIds' ] = [ ] ; foreach ( $ result -> getValue ( ) as $ feedItem ) { printf ( 'Feed item with feed item ID %d was added.%s' , $ feedItem -> getFeedItemId ( ) , PHP_EOL ) ; $ sitelinksData [ 'sitelinkFeedItemIds' ] [ ] = $ feedItem -> getFeedItemId ( ) ; } // Target the "aboutUs" sitelink to geographically target California. // See https://developers.google.com/adwords/api/docs/appendix/geotargeting // for location criteria of supported locations. self :: restrictFeedItemToGeoTarget ( $ adWordsServices , $ session , $ result -> getValue ( ) [ 5 ] , 21137 ) ; return $ sitelinksData ; }
Creates sitelinks feed items and add it to the feed.
Creates sitelinks feed items and add it to the feed .