examples/AdWords/v201809/Extensions/AddSitelinksUsingFeeds.php
private static function newSitelinkFeedItemAddOperation(
        array $sitelinksData,
        $text,
        $finalUrl,
        $line2,
        $line3,
        $restrictToLop = null
    ) {
        // Create the feed item attribute values for our text values.
        $linkTextAttributeValue = new FeedItemAttributeValue();
        $linkTextAttributeValue->setFeedAttributeId(
            $sitelinksData['linkTextFeedAttributeId']
        );
        $linkTextAttributeValue->setStringValue($text);
        $linkFinalUrlAttributeValue = new FeedItemAttributeValue();
        $linkFinalUrlAttributeValue->setFeedAttributeId(
            $sitelinksData['linkFinalUrlFeedAttributeId']
        );
        $linkFinalUrlAttributeValue->setStringValues([$finalUrl]);
        $line2AttributeValue = new FeedItemAttributeValue();
        $line2AttributeValue->setFeedAttributeId(
            $sitelinksData['line2FeedAttribute']
        );
        $line2AttributeValue->setStringValue($line2);
        $line3AttributeValue = new FeedItemAttributeValue();
        $line3AttributeValue->setFeedAttributeId(
            $sitelinksData['line3FeedAttribute']
        );
        $line3AttributeValue->setStringValue($line3);

        // Create the feed item.
        $item = new FeedItem();
        $item->setFeedId($sitelinksData['sitelinksFeedId']);
        $item->setAttributeValues(
            [
                $linkTextAttributeValue,
                $linkFinalUrlAttributeValue,
                $line2AttributeValue,
                $line3AttributeValue
            ]
        );

        // OPTIONAL: Restrict targeting only to people physically within the
        // location.
        if ($restrictToLop === true) {
            $item->setGeoTargetingRestriction(
                new FeedItemGeoRestriction(GeoRestriction::LOCATION_OF_PRESENCE)
            );
        }

        // Create the feed item operation.
        $operation = new FeedItemOperation();
        $operation->setOperand($item);
        $operation->setOperator(Operator::ADD);

        return $operation;
    }
private static function newSitelinkFeedItemAddOperation(
        array $sitelinksData,
        $text,
        $finalUrl,
        $line2,
        $line3,
        $restrictToLop = null
    ) {
        // Create the feed item attribute values for our text values.
        $linkTextAttributeValue = new FeedItemAttributeValue();
        $linkTextAttributeValue->setFeedAttributeId(
            $sitelinksData['linkTextFeedAttributeId']
        );
        $linkTextAttributeValue->setStringValue($text);
        $linkFinalUrlAttributeValue = new FeedItemAttributeValue();
        $linkFinalUrlAttributeValue->setFeedAttributeId(
            $sitelinksData['linkFinalUrlFeedAttributeId']
        );
        $linkFinalUrlAttributeValue->setStringValues([$finalUrl]);
        $line2AttributeValue = new FeedItemAttributeValue();
        $line2AttributeValue->setFeedAttributeId(
            $sitelinksData['line2FeedAttribute']
        );
        $line2AttributeValue->setStringValue($line2);
        $line3AttributeValue = new FeedItemAttributeValue();
        $line3AttributeValue->setFeedAttributeId(
            $sitelinksData['line3FeedAttribute']
        );
        $line3AttributeValue->setStringValue($line3);

        // Create the feed item.
        $item = new FeedItem();
        $item->setFeedId($sitelinksData['sitelinksFeedId']);
        $item->setAttributeValues(
            [
                $linkTextAttributeValue,
                $linkFinalUrlAttributeValue,
                $line2AttributeValue,
                $line3AttributeValue
            ]
        );

        // OPTIONAL: Restrict targeting only to people physically within the
        // location.
        if ($restrictToLop === true) {
            $item->setGeoTargetingRestriction(
                new FeedItemGeoRestriction(GeoRestriction::LOCATION_OF_PRESENCE)
            );
        }

        // Create the feed item operation.
        $operation = new FeedItemOperation();
        $operation->setOperand($item);
        $operation->setOperator(Operator::ADD);

        return $operation;
    }
private static function newSitelinkFeedItemAddOperation ( array $ sitelinksData , $ text , $ finalUrl , $ line2 , $ line3 , $ restrictToLop = null ) { // Create the feed item attribute values for our text values. $ linkTextAttributeValue = new FeedItemAttributeValue ( ) ; $ linkTextAttributeValue -> setFeedAttributeId ( $ sitelinksData [ 'linkTextFeedAttributeId' ] ) ; $ linkTextAttributeValue -> setStringValue ( $ text ) ; $ linkFinalUrlAttributeValue = new FeedItemAttributeValue ( ) ; $ linkFinalUrlAttributeValue -> setFeedAttributeId ( $ sitelinksData [ 'linkFinalUrlFeedAttributeId' ] ) ; $ linkFinalUrlAttributeValue -> setStringValues ( [ $ finalUrl ] ) ; $ line2AttributeValue = new FeedItemAttributeValue ( ) ; $ line2AttributeValue -> setFeedAttributeId ( $ sitelinksData [ 'line2FeedAttribute' ] ) ; $ line2AttributeValue -> setStringValue ( $ line2 ) ; $ line3AttributeValue = new FeedItemAttributeValue ( ) ; $ line3AttributeValue -> setFeedAttributeId ( $ sitelinksData [ 'line3FeedAttribute' ] ) ; $ line3AttributeValue -> setStringValue ( $ line3 ) ; // Create the feed item. $ item = new FeedItem ( ) ; $ item -> setFeedId ( $ sitelinksData [ 'sitelinksFeedId' ] ) ; $ item -> setAttributeValues ( [ $ linkTextAttributeValue , $ linkFinalUrlAttributeValue , $ line2AttributeValue , $ line3AttributeValue ] ) ; // OPTIONAL: Restrict targeting only to people physically within the // location. if ( $ restrictToLop === true ) { $ item -> setGeoTargetingRestriction ( new FeedItemGeoRestriction ( GeoRestriction :: LOCATION_OF_PRESENCE ) ) ; } // Create the feed item operation. $ operation = new FeedItemOperation ( ) ; $ operation -> setOperand ( $ item ) ; $ operation -> setOperator ( Operator :: ADD ) ; return $ operation ; }
Creates a site link feed item and wraps it in an ADD operation.

@param array $sitelinksData IDs associated to created sitelinks feed
metadata
@param string $text the text of the sitelink
@param string $finalUrl the final URL of the sitelink
@param string $line2 the first line of the sitelink description
@param string $line3 the second line of the sitelink description
@param bool|null $restrictToLop whether to restrict the feed item to
location of presence
@return FeedItemOperation the created ADD operation of site link feed
item
Creates a site link feed item and wraps it in an ADD operation .