|
23 | 23 | use Microsoft\BingAds\V12\CampaignManagement\Keyword; |
24 | 24 | use Microsoft\BingAds\V12\CampaignManagement\Ad; |
25 | 25 | use Microsoft\BingAds\V12\CampaignManagement\AdType; |
| 26 | +use Microsoft\BingAds\V12\CampaignManagement\AdAdditionalField; |
26 | 27 | use Microsoft\BingAds\V12\CampaignManagement\ExpandedTextAd; |
27 | 28 | use Microsoft\BingAds\V12\CampaignManagement\Bid; |
28 | 29 | use Microsoft\BingAds\V12\CampaignManagement\BiddingScheme; |
|
262 | 263 | // Add the campaign, ad group, keywords, and ads |
263 | 264 |
|
264 | 265 | print "AddCampaigns\n"; |
265 | | - $addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns($GLOBALS['AuthorizationData']->AccountId, $campaigns); |
| 266 | + $addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns( |
| 267 | + $GLOBALS['AuthorizationData']->AccountId, |
| 268 | + $campaigns, |
| 269 | + false); |
266 | 270 | $nillableCampaignIds = $addCampaignsResponse->CampaignIds; |
267 | 271 | CampaignManagementExampleHelper::OutputArrayOfLong($nillableCampaignIds); |
268 | 272 | if(isset($addCampaignsResponse->PartialErrors->BatchError)){ |
|
412 | 416 | $index++; |
413 | 417 | } |
414 | 418 |
|
415 | | - CampaignManagementExampleHelper::UpdateCampaigns($GLOBALS['AuthorizationData']->AccountId, $updateCampaigns); |
| 419 | + CampaignManagementExampleHelper::UpdateCampaigns( |
| 420 | + $GLOBALS['AuthorizationData']->AccountId, |
| 421 | + $updateCampaigns, |
| 422 | + false); |
416 | 423 |
|
417 | 424 | $getCampaigns = CampaignManagementExampleHelper::GetCampaignsByIds( |
418 | 425 | $GLOBALS['AuthorizationData']->AccountId, |
|
465 | 472 | // As an exercise you can view the results before and after update. |
466 | 473 |
|
467 | 474 | $adTypes = array(AdType::AppInstall, AdType::DynamicSearch, AdType::ExpandedText, AdType::Product, AdType::Text); |
468 | | - $ads = CampaignManagementExampleHelper::GetAdsByAdGroupId($nillableAdGroupIds->long[0], $adTypes); |
469 | | - CampaignManagementExampleHelper::OutputArrayOfAd($ads); |
| 475 | + $adAdditionalFields = array(AdAdditionalField::TextPart2, AdAdditionalField::TitlePart3); |
| 476 | + $ads = CampaignManagementExampleHelper::GetAdsByAdGroupId( |
| 477 | + $nillableAdGroupIds->long[0], |
| 478 | + $adTypes, |
| 479 | + $adAdditionalFields); |
| 480 | + if(isset($ads->Ads)){ |
| 481 | + CampaignManagementExampleHelper::OutputArrayOfAd($ads->Ads); |
| 482 | + } |
470 | 483 |
|
471 | 484 | $updateAdsResponse = CampaignManagementExampleHelper::UpdateAds($nillableAdGroupIds->long[0], $updateAds); |
472 | | - $ads = CampaignManagementExampleHelper::GetAdsByAdGroupId($nillableAdGroupIds->long[0], $adTypes); |
473 | | - CampaignManagementExampleHelper::OutputArrayOfAd($ads); |
| 485 | + $ads = CampaignManagementExampleHelper::GetAdsByAdGroupId( |
| 486 | + $nillableAdGroupIds->long[0], |
| 487 | + $adTypes, |
| 488 | + $adAdditionalFields); |
| 489 | + if(isset($ads->Ads)){ |
| 490 | + CampaignManagementExampleHelper::OutputArrayOfAd($ads->Ads); |
| 491 | + } |
474 | 492 |
|
475 | 493 | // Here is a simple example that updates the keyword bid to use the ad group bid |
476 | 494 |
|
|
485 | 503 | // As an exercise you can view the results before and after update. |
486 | 504 |
|
487 | 505 | $keywords = CampaignManagementExampleHelper::GetKeywordsByAdGroupId($nillableAdGroupIds->long[0], null); |
488 | | - CampaignManagementExampleHelper::OutputArrayOfKeyword($keywords); |
| 506 | + if(isset($keywords->Keywords)){ |
| 507 | + CampaignManagementExampleHelper::OutputArrayOfKeyword($keywords->Keywords); |
| 508 | + } |
489 | 509 |
|
490 | 510 | $updateKeywordsResponse = CampaignManagementExampleHelper::UpdateKeywords( |
491 | 511 | $nillableAdGroupIds->long[0], |
492 | 512 | $updateKeywords, |
493 | 513 | null); |
494 | 514 | $keywords = CampaignManagementExampleHelper::GetKeywordsByAdGroupId($nillableAdGroupIds->long[0], null); |
495 | | - CampaignManagementExampleHelper::OutputArrayOfKeyword($keywords); |
496 | | - |
| 515 | + if(isset($keywords->Keywords)){ |
| 516 | + CampaignManagementExampleHelper::OutputArrayOfKeyword($keywords->Keywords); |
| 517 | + } |
| 518 | + |
497 | 519 | // As an exercise you can delete the keyword |
498 | 520 | CampaignManagementExampleHelper::DeleteKeywords($nillableAdGroupIds->long[0], array($nillableKeywordIds->long[1])); |
499 | 521 |
|
|
0 commit comments