examples/AdWords/v201809/AdvancedOperations/AddDynamicPageFeed.php
private static function createFeed(
        AdWordsServices $adWordsServices,
        AdWordsSession $session
    ) {
        $feedService = $adWordsServices->get($session, FeedService::class);

        // Create feed attributes.
        $urlAttribute = new FeedAttribute();
        $urlAttribute->setType(FeedAttributeType::URL_LIST);
        $urlAttribute->setName('Page URL');

        $labelAttribute = new FeedAttribute();
        $labelAttribute->setType(FeedAttributeType::STRING_LIST);
        $labelAttribute->setName('Label');

        // Create the feed.
        $dsaPageFeed = new Feed();
        $dsaPageFeed->setName('DSA Feed #' . uniqid());
        $dsaPageFeed->setAttributes([$urlAttribute, $labelAttribute]);
        $dsaPageFeed->setOrigin(FeedOrigin::USER);

        // Create the feed operation and add it on the server.
        $operation = new FeedOperation();
        $operation->setOperator(Operator::ADD);
        $operation->setOperand($dsaPageFeed);
        $result = $feedService->mutate([$operation]);

        // Holds the feeds metadata.
        $feedDetails = new DSAFeedDetails();

        $savedFeed = $result->getValue()[0];
        $feedDetails->feedId = $savedFeed->getId();

        $savedAttributes = $savedFeed->getAttributes();
        $feedDetails->urlAttributeId = $savedAttributes[0]->getId();
        $feedDetails->labelAttributeId = $savedAttributes[1]->getId();

        // Print out some information about the created feed.
        printf(
            "Feed with name '%s', ID %d with urlAttributeId %d and labelAttributeId %d was created.\n",
            $savedFeed->getName(),
            $feedDetails->feedId,
            $feedDetails->urlAttributeId,
            $feedDetails->labelAttributeId
        );

        return $feedDetails;
    }
private static function createFeed(
        AdWordsServices $adWordsServices,
        AdWordsSession $session
    ) {
        $feedService = $adWordsServices->get($session, FeedService::class);

        // Create feed attributes.
        $urlAttribute = new FeedAttribute();
        $urlAttribute->setType(FeedAttributeType::URL_LIST);
        $urlAttribute->setName('Page URL');

        $labelAttribute = new FeedAttribute();
        $labelAttribute->setType(FeedAttributeType::STRING_LIST);
        $labelAttribute->setName('Label');

        // Create the feed.
        $dsaPageFeed = new Feed();
        $dsaPageFeed->setName('DSA Feed #' . uniqid());
        $dsaPageFeed->setAttributes([$urlAttribute, $labelAttribute]);
        $dsaPageFeed->setOrigin(FeedOrigin::USER);

        // Create the feed operation and add it on the server.
        $operation = new FeedOperation();
        $operation->setOperator(Operator::ADD);
        $operation->setOperand($dsaPageFeed);
        $result = $feedService->mutate([$operation]);

        // Holds the feeds metadata.
        $feedDetails = new DSAFeedDetails();

        $savedFeed = $result->getValue()[0];
        $feedDetails->feedId = $savedFeed->getId();

        $savedAttributes = $savedFeed->getAttributes();
        $feedDetails->urlAttributeId = $savedAttributes[0]->getId();
        $feedDetails->labelAttributeId = $savedAttributes[1]->getId();

        // Print out some information about the created feed.
        printf(
            "Feed with name '%s', ID %d with urlAttributeId %d and labelAttributeId %d was created.\n",
            $savedFeed->getName(),
            $feedDetails->feedId,
            $feedDetails->urlAttributeId,
            $feedDetails->labelAttributeId
        );

        return $feedDetails;
    }
private static function createFeed ( AdWordsServices $ adWordsServices , AdWordsSession $ session ) { $ feedService = $ adWordsServices -> get ( $ session , FeedService :: class ) ; // Create feed attributes. $ urlAttribute = new FeedAttribute ( ) ; $ urlAttribute -> setType ( FeedAttributeType :: URL_LIST ) ; $ urlAttribute -> setName ( 'Page URL' ) ; $ labelAttribute = new FeedAttribute ( ) ; $ labelAttribute -> setType ( FeedAttributeType :: STRING_LIST ) ; $ labelAttribute -> setName ( 'Label' ) ; // Create the feed. $ dsaPageFeed = new Feed ( ) ; $ dsaPageFeed -> setName ( 'DSA Feed #' . uniqid ( ) ) ; $ dsaPageFeed -> setAttributes ( [ $ urlAttribute , $ labelAttribute ] ) ; $ dsaPageFeed -> setOrigin ( FeedOrigin :: USER ) ; // Create the feed operation and add it on the server. $ operation = new FeedOperation ( ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operation -> setOperand ( $ dsaPageFeed ) ; $ result = $ feedService -> mutate ( [ $ operation ] ) ; // Holds the feeds metadata. $ feedDetails = new DSAFeedDetails ( ) ; $ savedFeed = $ result -> getValue ( ) [ 0 ] ; $ feedDetails -> feedId = $ savedFeed -> getId ( ) ; $ savedAttributes = $ savedFeed -> getAttributes ( ) ; $ feedDetails -> urlAttributeId = $ savedAttributes [ 0 ] -> getId ( ) ; $ feedDetails -> labelAttributeId = $ savedAttributes [ 1 ] -> getId ( ) ; // Print out some information about the created feed. printf ( "Feed with name '%s', ID %d with urlAttributeId %d and labelAttributeId %d was created.\n" , $ savedFeed -> getName ( ) , $ feedDetails -> feedId , $ feedDetails -> urlAttributeId , $ feedDetails -> labelAttributeId ) ; return $ feedDetails ; }
Creates the feed for DSA page URLs.
Creates the feed for DSA page URLs .