examples/AdWords/v201809/CampaignManagement/AddCompleteCampaignsUsingBatchJob.php
private static function buildCampaignOperations(
        $namePrefix,
        BudgetOperation $budgetOperation
    ) {
        $budgetId = $budgetOperation->getOperand()->getBudgetId();

        $operations = [];
        for ($i = 0; $i < self::NUMBER_OF_CAMPAIGNS_TO_ADD; $i++) {
            $campaign = new Campaign();
            $campaign->setId(--self::$temporaryId);
            $campaign->setName(
                sprintf(
                    'Batch Campaign %s.%s',
                    $namePrefix,
                    strval($campaign->getId())
                )
            );

            // Recommendation: Set the campaign to PAUSED when creating it to stop
            // the ads from immediately serving. Set to ENABLED once you've added
            // targeting and the ads are ready to serve.
            $campaign->setStatus(CampaignStatus::PAUSED);
            $campaign->setAdvertisingChannelType(AdvertisingChannelType::SEARCH);

            $budget = new Budget();
            $budget->setBudgetId($budgetId);
            $campaign->setBudget($budget);
            $biddingStrategyConfiguration = new BiddingStrategyConfiguration();
            $biddingStrategyConfiguration->setBiddingStrategyType(
                BiddingStrategyType::MANUAL_CPC
            );

            // You can optionally provide a bidding scheme in place of the type.
            $cpcBiddingScheme = new ManualCpcBiddingScheme();
            $biddingStrategyConfiguration->setBiddingScheme($cpcBiddingScheme);

            $campaign->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

            $operation = new CampaignOperation();
            $operation->setOperand($campaign);
            $operation->setOperator(Operator::ADD);
            $operations[] = $operation;
        }

        return $operations;
    }
private static function buildCampaignOperations(
        $namePrefix,
        BudgetOperation $budgetOperation
    ) {
        $budgetId = $budgetOperation->getOperand()->getBudgetId();

        $operations = [];
        for ($i = 0; $i < self::NUMBER_OF_CAMPAIGNS_TO_ADD; $i++) {
            $campaign = new Campaign();
            $campaign->setId(--self::$temporaryId);
            $campaign->setName(
                sprintf(
                    'Batch Campaign %s.%s',
                    $namePrefix,
                    strval($campaign->getId())
                )
            );

            // Recommendation: Set the campaign to PAUSED when creating it to stop
            // the ads from immediately serving. Set to ENABLED once you've added
            // targeting and the ads are ready to serve.
            $campaign->setStatus(CampaignStatus::PAUSED);
            $campaign->setAdvertisingChannelType(AdvertisingChannelType::SEARCH);

            $budget = new Budget();
            $budget->setBudgetId($budgetId);
            $campaign->setBudget($budget);
            $biddingStrategyConfiguration = new BiddingStrategyConfiguration();
            $biddingStrategyConfiguration->setBiddingStrategyType(
                BiddingStrategyType::MANUAL_CPC
            );

            // You can optionally provide a bidding scheme in place of the type.
            $cpcBiddingScheme = new ManualCpcBiddingScheme();
            $biddingStrategyConfiguration->setBiddingScheme($cpcBiddingScheme);

            $campaign->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

            $operation = new CampaignOperation();
            $operation->setOperand($campaign);
            $operation->setOperator(Operator::ADD);
            $operations[] = $operation;
        }

        return $operations;
    }
private static function buildCampaignOperations ( $ namePrefix , BudgetOperation $ budgetOperation ) { $ budgetId = $ budgetOperation -> getOperand ( ) -> getBudgetId ( ) ; $ operations = [ ] ; for ( $ i = 0 ; $ i < self :: NUMBER_OF_CAMPAIGNS_TO_ADD ; $ i ++ ) { $ campaign = new Campaign ( ) ; $ campaign -> setId ( -- self :: $ temporaryId ) ; $ campaign -> setName ( sprintf ( 'Batch Campaign %s.%s' , $ namePrefix , strval ( $ campaign -> getId ( ) ) ) ) ; // Recommendation: Set the campaign to PAUSED when creating it to stop // the ads from immediately serving. Set to ENABLED once you've added // targeting and the ads are ready to serve. $ campaign -> setStatus ( CampaignStatus :: PAUSED ) ; $ campaign -> setAdvertisingChannelType ( AdvertisingChannelType :: SEARCH ) ; $ budget = new Budget ( ) ; $ budget -> setBudgetId ( $ budgetId ) ; $ campaign -> setBudget ( $ budget ) ; $ biddingStrategyConfiguration = new BiddingStrategyConfiguration ( ) ; $ biddingStrategyConfiguration -> setBiddingStrategyType ( BiddingStrategyType :: MANUAL_CPC ) ; // You can optionally provide a bidding scheme in place of the type. $ cpcBiddingScheme = new ManualCpcBiddingScheme ( ) ; $ biddingStrategyConfiguration -> setBiddingScheme ( $ cpcBiddingScheme ) ; $ campaign -> setBiddingStrategyConfiguration ( $ biddingStrategyConfiguration ) ; $ operation = new CampaignOperation ( ) ; $ operation -> setOperand ( $ campaign ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operations [ ] = $ operation ; } return $ operations ; }
Builds objects of CampaignOperation for creating a campaign using the ID of
budget in the specified budget operation.

@param string $namePrefix a prefix string used to name campaigns
@param BudgetOperation $budgetOperation an object of BudgetOperation
@return array an array of CampaignOperation
Builds objects of CampaignOperation for creating a campaign using the ID of budget in the specified budget operation .