Monday, 27 June 2016

Re: Add/Remove target location of campaign

Hello Peter,

Its worked now. I rearrange sequence of these two lines:
$campaignCriterionService =
        $user->GetService('
CampaignCriterionService', ADWORDS_VERSION);
        $user->SetClientCustomerId(base64_decode($ajaxData['clientId']));


Now working fine. Thank you for your response and guidance.
 :):)

On Monday, June 27, 2016 at 12:12:57 PM UTC+5:30, Sachin Kumar wrote:
Hello Team,

Goal: To add/remove target location in campaign

I want to add location in campaign target location. To achieve this I am using this code:



$campaignCriterionService =
        $user->GetService('CampaignCriterionService', ADWORDS_VERSION);
        $user->SetClientCustomerId(base64_decode($ajaxData['clientId']));
        //echo '<pre>';
        //print_r($ajaxData);die();
        $campaignCriteria = array();
       
        // Create locations. The IDs can be found in the documentation or retrieved
        // with the LocationCriterionService.
        $location = new Location();
        $location->id = intval($ajaxData['Target']);   // location id e.g. 2840 etc.    
       
        //$campaignCriteria[] = new CampaignCriterion($ajaxData['CampaignId'], null, $location);
       
        $campaignCriteria[] = new CampaignCriterion(intval($ajaxData['CampaignId']), null, $location);

       
        // Create operations.
          $operations = array();
          foreach ($campaignCriteria as $campaignCriterion) {
            $operations[] = new CampaignCriterionOperation($campaignCriterion, 'ADD');
        }
       
        // Make the mutate request.
        $result = $campaignCriterionService->mutate($operations);


But this giving me following error:

<br />
<b>Fatal error</b>:  Uncaught SoapFault exception: [soap:Server] [EntityNotFound.INVALID_ID @ operations
[0].operand.campaignId; trigger:'CampaignId: 254533954'] in /home/bergstromdev/public_html/Google/Api
/Ads/Common/Lib/AdsSoapClient.php:216
Stack trace:
#0 /home/bergstromdev/public_html/Google/Api/Ads/Common/Lib/AdsSoapClient.php(216): SoapClient-&gt;__soapCall
('mutate', Array, NULL, Array, Array)
#1 /home/bergstromdev/public_html/Google/Api/Ads/AdWords/v201603/CampaignCriterionService.php(7969):
 AdsSoapClient-&gt;__soapCall('mutate', Array)
#2 /home/bergstromdev/public_html/lib/Targetting.class.php(42): CampaignCriterionService-&gt;mutate(Array
)
#3 /home/bergstromdev/public_html/ajaxCall.php(62): Targetting-&gt;addLocationTarget(Object(AdWordsUser
), Array)
#4 {main}
  thrown in <b>/home/bergstromdev/public_html/Google/Api/Ads/Common/Lib/AdsSoapClient.php</b> on line
 <b>216</b><br />



Kindly guide me how I can escape these errors. I pick this code from examples provided in the php library



--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and Google+:
https://googleadsdeveloper.blogspot.com/
https://plus.google.com/+GoogleAdsDevelopers/posts
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords 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+unsubscribe@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 Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/aa052a4d-3f25-437d-8a7e-38bb85fe6762%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment