Thank you Peter for your reply. Your points helped me to find a way.
I got the way to add/update/remove the Ad schedule bid modifiers for different time slots. One thing I want to know, How I can get the list of fields which can be selected from any service e.g.('CampaignCriterionService')?
Thanks in advance.
On Sunday, July 24, 2016 at 10:37:32 AM UTC+5:30, Sachin Kumar wrote:
-- I got the way to add/update/remove the Ad schedule bid modifiers for different time slots. One thing I want to know, How I can get the list of fields which can be selected from any service e.g.('CampaignCriterionService')?
Thanks in advance.
On Sunday, July 24, 2016 at 10:37:32 AM UTC+5:30, Sachin Kumar wrote:
Hello Team,
I want to set different bidModifier for different time slot e.g Time: 11-12 bidModifier=1.5, Time: 14-15 bidModifier=1.3.
To achieve this I used this code:
public function update_hour_bid(AdWordsUser $user,$clientId = null,$data=null){
$newBid = explode("&", $data['newBid']);
$user = new AdwordsUser();
$user->SetClientCustomerId($clientId); // ClientId
$campaignCriterionService = $user->GetService('CampaignCriterionService', ADWORDS_VERSION);
$operations = array();
$campaignID = $data['campaignid'];
//$days = array('MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY' ,'SATURDAY','SUNDAY');
foreach($newBid as $bid){
if(!empty($bid)){
//foreach($days as $day) {
$Biddata = explode("=", $bid);
//$Biddata[0] // day
//$Biddata[1] // hour
//$Biddata[2] // bid
$hour = explode('-',$Biddata[1]);
// $hour[0] // start hour
// $hour[1] // end hour
//Set Variables
$adSchedule = new AdSchedule();
$adSchedule->dayOfWeek = trim($Biddata[0]);
$adSchedule->startHour = trim($hour[0]);
$adSchedule->startMinute = 'ZERO';
$adSchedule->endHour = trim($hour[1]);
$adSchedule->endMinute = 'ZERO';
//$adSchedule->bidModifier = trim($Biddata[2]);
$adScheduleCriterion = new CampaignCriterion();//AdScheduleCriterion();
$adScheduleCriterion->campaignId = $campaignID;
$adScheduleCriterion->bidModifier = trim($Biddata[2]);
$adScheduleCriterion->criterion = $adSchedule;
//Create the Operation
$operation = new CampaignCriterionOperation();
$operation->operand = $adScheduleCriterion;
$operation->operator = 'ADD';
$operations[] = $operation;
//echo '<pre>';print_r($operations);die();
}
}
//Mutate!
$result = $campaignCriterionService->mutate($operations);
echo '<pre>';print_r($result);die();
if (count($results->value)){
return 1;
}else{
return 0;
}
}
When I use $operation->operator = 'ADD' this code generate
<b>Fatal error</b>: Uncaught SoapFault exception: [soap:Server] [CriterionError.AD_SCHEDULE_TIME_INTERVALS_OVERLAP
@ operations[0].operand.criterion; trigger:'Existing schedule: AdSchedule{id=CriterionId{id= 320824}
, dayOfWeek=WEDNESDAY, startHour=2, startMinute=ZERO, endHour=6, endMinute=ZERO}', RangeError.TOO_LOW
@ operations[0].operand.bidModifier,
When I use $operation->operator = 'SET' this generate error that criteria Id is required.
Kindly suggest me any change in this code so that I can set different bidModifier for different time slot.
Thanks & Regards
Sachin Kumar
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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/07df55be-1071-4e3c-8662-f0439a0facfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment