Hi, I'm trying to create an UniversalAppCampaign.

I send a request to create an UAC but API returns error messages 
According to error messages, It seems I sent wrong type about 
'universalAppBiddingStrategyGoalType'

(here's an part of error message what API 
retrun)<ns1:universalAppBiddingStrategyGoalType>OPTIMIZE_FOR_INSTALL_CONVERSION_VOLUME</ns1:universalAppBiddingStrategyGoalType>
  

And I'd modified my codes as Google Adwords Guide describes also, 
but API still returned same error message 

I attach my codes and a screenshot which I captured at my server monitor 
so please check them and give me a feedback 
thanks  

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/0428514b-a982-433e-b922-808622419aa2n%40googlegroups.com.
<?php


namespace Google\AdsApi\Examples\AdWords\v201809\DboundUpdate;

require __DIR__ . '/../../../../vendor/autoload.php';

use Google\AdsApi\AdWords\AdWordsServices;
use Google\AdsApi\AdWords\AdWordsSession;
use Google\AdsApi\AdWords\AdWordsSessionBuilder;
use Google\AdsApi\AdWords\v201809\cm\AdvertisingChannelSubType;
use Google\AdsApi\AdWords\v201809\cm\AdvertisingChannelType;
use Google\AdsApi\AdWords\v201809\cm\BiddingStrategyConfiguration;
use Google\AdsApi\AdWords\v201809\cm\BiddingStrategyType;
use Google\AdsApi\AdWords\v201809\cm\Budget;
use Google\AdsApi\AdWords\v201809\cm\BudgetBudgetDeliveryMethod;
use Google\AdsApi\AdWords\v201809\cm\BudgetOperation;
use Google\AdsApi\AdWords\v201809\cm\BudgetService;
use Google\AdsApi\AdWords\v201809\cm\Campaign;
use Google\AdsApi\AdWords\v201809\cm\CampaignCriterion;
use Google\AdsApi\AdWords\v201809\cm\CampaignCriterionOperation;
use Google\AdsApi\AdWords\v201809\cm\CampaignCriterionService;
use Google\AdsApi\AdWords\v201809\cm\CampaignOperation;
use Google\AdsApi\AdWords\v201809\cm\CampaignService;
use Google\AdsApi\AdWords\v201809\cm\CampaignStatus;
use Google\AdsApi\AdWords\v201809\cm\GeoTargetTypeSetting;
use Google\AdsApi\AdWords\v201809\cm\GeoTargetTypeSettingNegativeGeoTargetType;
use Google\AdsApi\AdWords\v201809\cm\Language;
use Google\AdsApi\AdWords\v201809\cm\Location;
use Google\AdsApi\AdWords\v201809\cm\MobileApplicationVendor;
use Google\AdsApi\AdWords\v201809\cm\Money;
use Google\AdsApi\AdWords\v201809\cm\Operator;
use Google\AdsApi\AdWords\v201809\cm\SelectiveOptimization;
use Google\AdsApi\AdWords\v201809\cm\TargetCpaBiddingScheme;
use Google\AdsApi\AdWords\v201809\cm\UniversalAppBiddingStrategyGoalType;
use Google\AdsApi\AdWords\v201809\cm\UniversalAppCampaignSetting;
use Google\AdsApi\Common\OAuth2TokenBuilder;

/**
    [AppPromotion Insert Logic]
    1. view단에서 AppPromotion Campaign 정보 기입
    2. 입력된 데이터들 Dbound_GoogleController/adwordsAppPromotionInsertAction으로 보내어 가공
    3. adwordsAppPromotionInsertAction 가공된 데이터들은 SetAppPromotionCampaignInsert로 
encode하여 전송
    4. SetAppPromotionCampaignInsert에서 set형식으로 저장후 API 호출
    5. 호출 후 return된 데이터 다시 가공하여  
Dbound_GoogleController/adwordsAppPromotionInsertAction으로 전송
    6. 수신한 데이터들 가공하여 insert관련 history테이블에 저장
 **/

class SetAppPromotionCampaignInsert
{
    public static function runExample(
        AdWordsServices $adWordsServices,
        AdWordsSessionBuilder $sessionBuilder,
        $customerId,
        $datas
    ) {
        $rows = json_decode($datas);
        $session = $sessionBuilder->build();

        $campaignService = $adWordsServices->get($session, 
CampaignService::class);

        // Create campaign with some properties set.
        $campaign = new Campaign();
        $campaign->setName($rows->CampaignName);
        // 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);

        // Set the advertising channel and subchannel types for Universal app
        // campaigns.
        
$campaign->setAdvertisingChannelType(AdvertisingChannelType::MULTI_CHANNEL);
        $campaign->setAdvertisingChannelSubType(
            AdvertisingChannelSubType::UNIVERSAL_APP_CAMPAIGN
        );

        // Set the campaign's bidding strategy. Universal App campaigns
        // only support TARGET_CPA bidding strategy.
        $biddingStrategyConfiguration = new BiddingStrategyConfiguration();
        
$biddingStrategyConfiguration->setBiddingStrategyType($rows->biddingStrategyType);

        // Set the target CPA to $1 / app install.
        $bidAmount = $rows->TargetCpaBiddingSchemeTargetCpa;
        $bidAmount = $bidAmount*1000000;
        $biddingScheme = new TargetCpaBiddingScheme();
        $money = new Money();
        $money->setMicroAmount($bidAmount);
        $biddingScheme->setTargetCpa($money);

        $biddingStrategyConfiguration->setBiddingScheme($biddingScheme);
        
$campaign->setBiddingStrategyConfiguration($biddingStrategyConfiguration);

        // Set shared budget (required).
        $campaign->setBudget(new Budget());
        $campaign->getBudget()->setBudgetId(
            self::createBudget($adWordsServices, $session, $rows->budget)
        );

        // Optional: Set the start date.
        $campaign->setStartDate($rows->startDate);

        if(!empty($rows->endDate)){
            // Optional: Set the end date.
            $campaign->setEndDate($rows->endDate);
        }

        // Set the campaign's assets and ad text ideas. These values will be 
used to
        // generate ads.
        $universalAppSetting = new UniversalAppCampaignSetting();
        $universalAppSetting->setAppId($rows->appId);
        $universalAppSetting->setAppVendor(
            MobileApplicationVendor::VENDOR_GOOGLE_MARKET
        );
        $universalAppSetting->setDescription1('A cool puzzle game');
        $universalAppSetting->setDescription2('Remove connected blocks');
        $universalAppSetting->setDescription3('3 difficulty levels');
        $universalAppSetting->setDescription4('4 colorful fun skins');

        // Optional: You can set up to 20 image assets for your campaign.
        // See UploadImage.php for an example on how to upload images.
        //
        // $universalAppSetting->imageMediaIds = [INSERT_IMAGE_MEDIA_ID_HERE];

        // Optimize this campaign for getting new users for your app.
        
$universalAppSetting->setUniversalAppBiddingStrategyGoalType($rows->biddingStrategyGoalType);

        // If you select bidding strategy goal type as
        // OPTIMIZE_FOR_IN_APP_CONVERSION_VOLUME, then you may specify a set of
        // conversion types for in-app actions to optimize the campaign towards.
        // Conversion type IDs can be retrieved using 
ConversionTrackerService.get.
        //
        // $campaign->selectiveOptimization = new SelectiveOptimization();
        // $campaign->selectiveOptimization->conversionTypeIds = [
        //     INSERT_CONVERSION_TYPE_ID_1_HERE,
        //     INSERT_CONVERSION_TYPE_ID_2_HERE
        // ];
        if(!empty($rows->ConversionTypeIds) && count($rows->ConversionTypeIds) 
> 0){
            $campaign->setSelectiveOptimization(new SelectiveOptimization());
            
$campaign->getSelectiveOptimization()->setConversionTypeIds($rows->ConversionTypeIds);
        }

        // Optional: Set the campaign settings for Advanced location options.
        $geoTargetTypeSetting = new GeoTargetTypeSetting();
        $geoTargetTypeSetting->setNegativeGeoTargetType(
            GeoTargetTypeSettingNegativeGeoTargetType::LOCATION_OF_PRESENCE
        );
        $campaign->setSettings([$universalAppSetting, $geoTargetTypeSetting]);

        // Create a campaign operation and add it to the operations list.
        $operations = [];
        $operation = new CampaignOperation();
        $operation->setOperand($campaign);
        $operation->setOperator(Operator::ADD);
        $operations[] = $operation;

        // Create the campaign on the server and print out some information for 
the
        // campaign.
        $result = $campaignService->mutate($operations);
        $test = $result->getValue()[0];
        print_r($test);
        /*
        foreach ($result->getValue() as $campaign) {
            printf(
                "Universal App Campaign with name '%s' and ID %d was added.\n",
                $campaign->getName(),
                $campaign->getId()
            );
            // Optional: Set the campaign's location and language targeting. No 
other
            // targeting criteria can be used for Universal App campaigns.
            self::setCampaignTargetingCriteria(
                $campaign->getId(),
                $adWordsServices,
                $session
            );
        }
        */
    }

    /**
     * Creates the budget for the campaign.
     */
    private static function createBudget(
        AdWordsServices $adWordsServices,
        AdWordsSession $session,
        $budgetAmount
    ) {
        $budgetService = $adWordsServices->get($session, BudgetService::class);

        // Create the shared budget (required).
        $budget = new Budget();
        $budget->setName('Interplanetary Cruise Budget #' . uniqid());
        $money = new Money();
        $budgetAmount = $budgetAmount*1000000;
        $money->setMicroAmount($budgetAmount);
        $budget->setAmount($money);
        $budget->setDeliveryMethod(BudgetBudgetDeliveryMethod::STANDARD);

        // Universal App campaigns don't support shared budgets.
        $budget->setIsExplicitlyShared(false);
        $operations = [];

        // Create a budget operation.
        $operation = new BudgetOperation();
        $operation->setOperand($budget);
        $operation->setOperator(Operator::ADD);
        $operations[] = $operation;

        // Create the budget on the server.
        $result = $budgetService->mutate($operations);
        $budget = $result->getValue()[0];

        printf(
            "Budget with name '%s' and ID %d was created.\n",
            $budget->getName(),
            $budget->getBudgetId()
        );


        return $budget->getBudgetId();
    }

    /**
     * Sets the campaign's targeting criteria.
     */
    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()
            );
        }
    }

    public static function main($clientCustomerId, $datas)
    {
        // Generate a refreshable OAuth2 credential for authentication.
        $oAuth2Credential = (new OAuth2TokenBuilder())->fromFile()->build();

        // Construct an API session configured from a properties file and the
        // OAuth2 credentials above.
        $builder = (new 
AdWordsSessionBuilder())->fromFile()->withOAuth2Credential($oAuth2Credential);

        if($clientCustomerId != '')
            $builder->withClientCustomerId($clientCustomerId);

        $sessionBuilder = $builder;

        self::runExample(
            new AdWordsServices(),
            $sessionBuilder,
            $clientCustomerId,
            $datas
        );
    }
}

$clientCustomerId = $argv[1];
$datas = $argv[2];

SetAppPromotionCampaignInsert::main($clientCustomerId, $datas);
php SetAppPromotionCampaignInsert.php 5073046955 
'{"campaignId":"","customerId":"5073046955","appId":"apms.apro.rush","CampaignName":"test1","startDate":"20201204","endDate":"20220205","endDateChk":"Y","location":"other","language":["1072","1022","1010","1013","1009","1000","1012"],"positiveGeoTargetType":"DONT_CARE","negativeGeoTargetType":"DONT_CARE","budget":"1111","budgetId":null,"locationTarget":["2646"],"locationNegative":["1009871"],"biddingStrategyType":"TARGET_CPA","biddingStrategyGoalType":"OPTIMIZE_FOR_INSTALL_CONVERSION_VOLUME","conversionTypeIds":null,"target_check":null,"TargetCpaBiddingSchemeTargetCpa":"11","business_action_inapp":null,"target_cost_per_conversion_inapp":null}'
[2020-12-03T17:32:24.485432+09:00] AW_SOAP.INFO: clientCustomerId=5073046955 
operations=1 service=BudgetService method=mutate responseTime=229 
requestId=0005b58b32fe14400aa7868f83039e94 server=adwords.google.com isFault=0 
faultMessage=  
Budget with name 'Interplanetary Cruise Budget #5fc8a29777a64' and ID 
7693704454 was created.
[2020-12-03T17:32:25.176071+09:00] AW_SOAP.WARNING: clientCustomerId=5073046955 
operations=1 service=CampaignService method=mutate responseTime=243 
requestId=0005b58b330829650a626f14cd099813 server=adwords.google.com isFault=1 
faultMessage=[OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE @ 
operations[0].operand.settings]  
[2020-12-03T17:32:25.176131+09:00] AW_SOAP.NOTICE: POST 
/api/adwords/cm/v201809/CampaignService?wsdl HTTP/1.1
Host: adwords.google.com
Connection: close
User-Agent: PHP-SOAP/7.3.18
Content-Type: text/xml; charset=utf-8
SOAPAction: ""
Content-Length: 2090
Authorization: REDACTED

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201809"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";><SOAP-ENV:Header><ns1:RequestHeader><ns1:clientCustomerId>5073046955</ns1:clientCustomerId><ns1:developerToken>REDACTED</ns1:developerToken><ns1:userAgent>unknown
 (AwApi-PHP, googleads-php-lib/47.0.0, 
PHP/7.3.18)</ns1:userAgent><ns1:validateOnly>false</ns1:validateOnly><ns1:partialFailure>false</ns1:partialFailure></ns1:RequestHeader></SOAP-ENV:Header><SOAP-ENV:Body><ns1:mutate><ns1:operations><ns1:operator>ADD</ns1:operator><ns1:operand><ns1:name>Interplanetary
 Cruise 
#5fc8a29777606</ns1:name><ns1:status>PAUSED</ns1:status><ns1:startDate>20201204</ns1:startDate><ns1:endDate>20211203</ns1:endDate><ns1:budget><ns1:budgetId>7693704454</ns1:budgetId></ns1:budget><ns1:settings
 
xsi:type="ns1:UniversalAppCampaignSetting"><ns1:appId>com.labpixies.colordrips</ns1:appId><ns1:appVendor>VENDOR_GOOGLE_MARKET</ns1:appVendor><ns1:description1>A
 cool puzzle game</ns1:description1><ns1:description2>Remove connected 
blocks</ns1:description2><ns1:description3>3 difficulty 
levels</ns1:description3><ns1:description4>4 colorful fun 
skins</ns1:description4><ns1:universalAppBiddingStrategyGoalType>OPTIMIZE_FOR_INSTALL_CONVERSION_VOLUME</ns1:universalAppBiddingStrategyGoalType></ns1:settings><ns1:settings
 
xsi:type="ns1:GeoTargetTypeSetting"><ns1:negativeGeoTargetType>LOCATION_OF_PRESENCE</ns1:negativeGeoTargetType></ns1:settings><ns1:advertisingChannelType>MULTI_CHANNEL</ns1:advertisingChannelType><ns1:advertisingChannelSubType>UNIVERSAL_APP_CAMPAIGN</ns1:advertisingChannelSubType><ns1:biddingStrategyConfiguration><ns1:biddingStrategyType>TARGET_CPA</ns1:biddingStrategyType><ns1:biddingScheme
 
xsi:type="ns1:TargetCpaBiddingScheme"><ns1:targetCpa><ns1:microAmount>1000000</ns1:microAmount></ns1:targetCpa></ns1:biddingScheme></ns1:biddingStrategyConfiguration></ns1:operand></ns1:operations></ns1:mutate></SOAP-ENV:Body></SOAP-ENV:Envelope>

HTTP/1.1 500 Internal Server Error
Content-Type: text/xml; charset=UTF-8
Date: Thu, 03 Dec 2020 08:32:25 GMT
Expires: Thu, 03 Dec 2020 08:32:25 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Content-Security-Policy: frame-ancestors 'self'
X-XSS-Protection: 1; mode=block
Server: GSE
Alt-Svc: h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; 
ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; 
ma=2592000; v="46,43"
Accept-Ranges: none
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked

<soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";><soap:Header><ResponseHeader
 
xmlns="https://adwords.google.com/api/adwords/cm/v201809";><requestId>0005b58b330829650a626f14cd099813</requestId><serviceName>CampaignService</serviceName><methodName>mutate</methodName><operations>1</operations><responseTime>243</responseTime></ResponseHeader></soap:Header><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>[OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE
 @ operations[0].operand.settings]</faultstring><detail><ApiExceptionFault 
xmlns="https://adwords.google.com/api/adwords/cm/v201809";><message>[OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE
 @ 
operations[0].operand.settings]</message><ApplicationException.Type>ApiException</ApplicationException.Type><errors
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:type="OperationAccessDenied"><fieldPath>operations[0].operand.settings</fieldPath><fieldPathElements><field>operations</field><index>0</index></fieldPathElements><fieldPathElements><field>operand</field></fieldPathElements><fieldPathElements><field>settings</field></fieldPathElements><trigger></trigger><errorString>OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE</errorString><ApiError.Type>OperationAccessDenied</ApiError.Type><reason>OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE</reason></errors></ApiExceptionFault></detail></soap:Fault></soap:Body></soap:Envelope>
  
PHP Fatal error:  Uncaught Google\AdsApi\AdWords\v201809\cm\ApiException: 
[OperationAccessDenied.OPERATION_NOT_PERMITTED_FOR_CAMPAIGN_TYPE @ 
operations[0].operand.settings] in 
/home/gitlab-runner/www/adcms/vendor/google/src/Google/AdsApi/Common/Util/Reflection.php:43
Stack trace:
#0 
/home/gitlab-runner/www/adcms/vendor/google/src/Google/AdsApi/Common/Util/Reflection.php(43):
 ReflectionClass->newInstanceArgs(Array)
#1 
/home/gitlab-runner/www/adcms/vendor/google/src/Google/AdsApi/Common/AdsSoapClient.php(202):
 Google\AdsApi\Common\Util\Reflection->createInstance('Google\\AdsApi\\A...', 
Array)
#2 
/home/gitlab-runner/www/adcms/vendor/google/src/Google/AdsApi/Common/AdsSoapClient.php(164):
 
Google\AdsApi\Common\AdsSoapClient->parseApiExceptionFromSoapFault(Object(SoapFault))
#3 
/home/gitlab-runner/www/adcms/vendor/google/src/Google/AdsApi/AdWords/v201809/cm/CampaignService.php(181):
 Google\AdsApi\Common\AdsSoapClient->__soapCall('mutate', Array)
#4 
/home/gitlab-runner/www/adcms/vendor/google/examples/AdWords/v201809/DboundInsert/Set
 in 
/home/gitlab-runner/www/adcms/vendor/google/src/Google/AdsApi/Common/Util/Reflection.php
 on line 43

Reply via email to