How to switch status for campaigns(php library)

19 views
Skip to first unread message

Volodymyr Palamarchuk

unread,
Dec 28, 2019, 7:51:32 AM12/28/19
to AdWords API and Google Ads API Forum
Hi there!

I need help, who know the possibility for the change statuses in campaign with Google\AdsApi\AdWords\v201809 (php library)

$adWordsServices = new AdWordsServices();
$campaignService = $adWordsServices->get($this->AdWordsSession, CampaignService::class);

// Create a campaign with Status.
$campaign = new Campaign();
$campaign->setId($google_campaign_id);
$campaign->setStatus(CampaignStatus::PAUSED);

// Create a campaign operation and add it to the list.
$operation = new CampaignOperation();
$operation->setOperand($campaign);
$operation->setOperator(Operator::SET);
$operations = [$operation];
// Update the campaign on the server.
$result = $campaignService->mutate($operations);
$val = $result->getValue()[0];

$res = [
'getId' => $val->getId(),
'getName' => $val->getName(),
'getStatus' => $val->getStatus()
];

I want to change statuses for campaigns from ENABLED to PAUSED and vice versa. But now I getting with my script campaign with ENABLED status all time...


Thanks advance
Volodymyr Palamarchuk

Volodymyr Palamarchuk

unread,
Dec 28, 2019, 10:26:34 AM12/28/19
to AdWords API and Google Ads API Forum
Hi there!

The question is not actual already:)
 


Thanks advance

Google Ads API Forum Advisor Prod

unread,
Dec 30, 2019, 2:29:42 PM12/30/19
to palamarch...@gmail.com, adwor...@googlegroups.com

Hello,

Thank you for writing to us. Please refer to this code sample to add campaigns via API. You need to set the campaign status to 'ENABLED' or 'PAUSED' using the below code snippet. Let us know if you need any additional information.

$campaign->setStatus(CampaignStatus::PAUSED);

Regards,
Nikisha Patel, Google Ads API Team



ref:_00D1U1174p._5001UOFPRt:ref
Reply all
Reply to author
Forward
0 new messages