examples/AdWords/v201809/AdvancedOperations/AddUniversalAppCampaign.php
private static function setCampaignTargetingCriteria(
        $campaignId,
        AdWordsServices $adWordsServices,
        AdWordsSession $session
    ) {
        $campaignCriterionService = $adWordsServices->get($session, CampaignCriterionService::class);

        $campaignCriteria = [];
        // Create locations. The IDs can be found in the documentation or retrieved
        // with the LocationCriterionService.
        $california = new Location();
        $california->setId(21137);
        $campaignCriteria[] = new CampaignCriterion($campaignId, null, $california);

        $mexico = new Location();
        $mexico->setId(2484);
        $campaignCriteria[] = new CampaignCriterion($campaignId, null, $mexico);

        // Create languages. The IDs can be found in the documentation or retrieved
        // with the ConstantDataService.
        $english = new Language();
        $english->setId(1000);
        $campaignCriteria[] = new CampaignCriterion($campaignId, null, $english);

        $spanish = new Language();
        $spanish->setId(1003);
        $campaignCriteria[] = new CampaignCriterion($campaignId, null, $spanish);

        // Create operations to add each of the criteria above.
        $operations = [];
        foreach ($campaignCriteria as $campaignCriterion) {
            $operation = new CampaignCriterionOperation();
            $operation->setOperand($campaignCriterion);
            $operation->setOperator(Operator::ADD);
            $operations[] = $operation;
        }

        // Set the campaign targets.
        $result = $campaignCriterionService->mutate($operations);

        // Display added campaign targets.
        foreach ($result->getValue() as $campaignCriterion) {
            printf(
                "Campaign criterion of type '%s' and ID %d was added.\n",
                $campaignCriterion->getCriterion()->getType(),
                $campaignCriterion->getCriterion()->getId()
            );
        }
    }
private static function setCampaignTargetingCriteria(
        $campaignId,
        AdWordsServices $adWordsServices,
        AdWordsSession $session
    ) {
        $campaignCriterionService = $adWordsServices->get($session, CampaignCriterionService::class);

        $campaignCriteria = [];
        // Create locations. The IDs can be found in the documentation or retrieved
        // with the LocationCriterionService.
        $california = new Location();
        $california->setId(21137);
        $campaignCriteria[] = new CampaignCriterion($campaignId, null, $california);

        $mexico = new Location();
        $mexico->setId(2484);
        $campaignCriteria[] = new CampaignCriterion($campaignId, null, $mexico);

        // Create languages. The IDs can be found in the documentation or retrieved
        // with the ConstantDataService.
        $english = new Language();
        $english->setId(1000);
        $campaignCriteria[] = new CampaignCriterion($campaignId, null, $english);

        $spanish = new Language();
        $spanish->setId(1003);
        $campaignCriteria[] = new CampaignCriterion($campaignId, null, $spanish);

        // Create operations to add each of the criteria above.
        $operations = [];
        foreach ($campaignCriteria as $campaignCriterion) {
            $operation = new CampaignCriterionOperation();
            $operation->setOperand($campaignCriterion);
            $operation->setOperator(Operator::ADD);
            $operations[] = $operation;
        }

        // Set the campaign targets.
        $result = $campaignCriterionService->mutate($operations);

        // Display added campaign targets.
        foreach ($result->getValue() as $campaignCriterion) {
            printf(
                "Campaign criterion of type '%s' and ID %d was added.\n",
                $campaignCriterion->getCriterion()->getType(),
                $campaignCriterion->getCriterion()->getId()
            );
        }
    }
private static function setCampaignTargetingCriteria ( $ campaignId , AdWordsServices $ adWordsServices , AdWordsSession $ session ) { $ campaignCriterionService = $ adWordsServices -> get ( $ session , CampaignCriterionService :: class ) ; $ campaignCriteria = [ ] ; // Create locations. The IDs can be found in the documentation or retrieved // with the LocationCriterionService. $ california = new Location ( ) ; $ california -> setId ( 21137 ) ; $ campaignCriteria [ ] = new CampaignCriterion ( $ campaignId , null , $ california ) ; $ mexico = new Location ( ) ; $ mexico -> setId ( 2484 ) ; $ campaignCriteria [ ] = new CampaignCriterion ( $ campaignId , null , $ mexico ) ; // Create languages. The IDs can be found in the documentation or retrieved // with the ConstantDataService. $ english = new Language ( ) ; $ english -> setId ( 1000 ) ; $ campaignCriteria [ ] = new CampaignCriterion ( $ campaignId , null , $ english ) ; $ spanish = new Language ( ) ; $ spanish -> setId ( 1003 ) ; $ campaignCriteria [ ] = new CampaignCriterion ( $ campaignId , null , $ spanish ) ; // Create operations to add each of the criteria above. $ operations = [ ] ; foreach ( $ campaignCriteria as $ campaignCriterion ) { $ operation = new CampaignCriterionOperation ( ) ; $ operation -> setOperand ( $ campaignCriterion ) ; $ operation -> setOperator ( Operator :: ADD ) ; $ operations [ ] = $ operation ; } // Set the campaign targets. $ result = $ campaignCriterionService -> mutate ( $ operations ) ; // Display added campaign targets. foreach ( $ result -> getValue ( ) as $ campaignCriterion ) { printf ( "Campaign criterion of type '%s' and ID %d was added.\n" , $ campaignCriterion -> getCriterion ( ) -> getType ( ) , $ campaignCriterion -> getCriterion ( ) -> getId ( ) ) ; } }
Sets the campaign's targeting criteria.
Sets the campaign s targeting criteria .