Ad Scheduling in PHP - 2015

48 views
Skip to first unread message

Doug Silksone

unread,
Oct 22, 2015, 3:57:57 PM10/22/15
to AdWords API Forum
Hey guys - First post here.

Purpose of this code section is to set Ad Scheduling between 00:00 - 04:00 every weekday. Unfortunately, the code I've written has been breaking the rest of my PHP script. 
At first glance, can you see where I'm going wrong? 


$campaignCriterionService =   $user->GetService('CampaignCriterionService', ADWORDS_VERSION);

  $operations
= array();
  $campaignID
= "XXX-XXX-XXXXX";
  $days
= array(
 
'MONDAY',
 
'TUESDAY',
 
'WEDNESDAY',
 
'THURSDAY',
 
'FRIDAY'
 
);
 
 
foreach($days as $day) {
 
//Set Variables
 $adSchedule
= new AdSchedule();
 $adSchedule
->dayOfWeek = $days[i];
 $adSchedule
->startHour = 0;
 $adSchedule
->startMinute = 'ZERO' ;
 $adSchedule
->endHour = 4;
 $adSchedule
->endMinute = 'ZERO' ;
 
 $adScheduleCriterion
= new AdScheduleCriterion();
 $adScheduleCriterion
->campaignId = $campaignID;
 $adScheduleCriterion
->criterion = $adSchedule;
 
 $adScheduleCriteria
[] = $adScheduleCriterion;
 
//Create the Operation
 $operation
= new CampaignCriterionOperation();
 $operation
->operand = $adScheduleCriterion;
 $operation
->operator = 'ADD';
 $operations
[] = $operation;
 
 
}
 
//Mutate!
  $result
= $CampaignCriterionService->mutate($operations);







tam...@brainlabsdigital.com

unread,
Nov 2, 2015, 8:59:42 AM11/2/15
to AdWords API Forum
 $adSchedule->dayOfWeek = $days[i];
Should this say $day rather than $days[i]?
Reply all
Reply to author
Forward
0 new messages