Skip to content

Commit

Permalink
Merge pull request #82 from BingAds/v11-12-7
Browse files Browse the repository at this point in the history
Update proxies and sample helpers
  • Loading branch information
eric-urban authored Oct 15, 2018
2 parents 5d851d1 + a08669e commit 7f71eae
Show file tree
Hide file tree
Showing 16 changed files with 166 additions and 23 deletions.
5 changes: 4 additions & 1 deletion samples/V12/AdExtensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@
$campaigns[] = $campaign;

print "AddCampaigns\n";
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns($GLOBALS['AuthorizationData']->AccountId, $campaigns);
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns(
$GLOBALS['AuthorizationData']->AccountId,
$campaigns,
false);
$nillableCampaignIds = $addCampaignsResponse->CampaignIds;
CampaignManagementExampleHelper::OutputArrayOfLong($nillableCampaignIds);
if(isset($addCampaignsResponse->PartialErrors->BatchError)){
Expand Down
3 changes: 2 additions & 1 deletion samples/V12/AudienceCampaigns.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
print "AddCampaigns\n";
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns(
$GLOBALS['AuthorizationData']->AccountId,
$campaigns);
$campaigns,
false);
$nillableCampaignIds = $addCampaignsResponse->CampaignIds;
CampaignManagementExampleHelper::OutputArrayOfLong($nillableCampaignIds);
if(isset($addCampaignsResponse->PartialErrors->BatchError)){
Expand Down
68 changes: 63 additions & 5 deletions samples/V12/CampaignManagementExampleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ static function AddCampaignCriterions(
}
static function AddCampaigns(
$accountId,
$campaigns)
$campaigns,
$includeDynamicSearchAdsSource)
{
$GLOBALS['CampaignManagementProxy']->SetAuthorizationData($GLOBALS['AuthorizationData']);
$GLOBALS['Proxy'] = $GLOBALS['CampaignManagementProxy'];
Expand All @@ -215,6 +216,7 @@ static function AddCampaigns(

$request->AccountId = $accountId;
$request->Campaigns = $campaigns;
$request->IncludeDynamicSearchAdsSource = $includeDynamicSearchAdsSource;

return $GLOBALS['CampaignManagementProxy']->GetService()->AddCampaigns($request);
}
Expand Down Expand Up @@ -732,7 +734,8 @@ static function GetAdGroupsByIds(
}
static function GetAdsByAdGroupId(
$adGroupId,
$adTypes)
$adTypes,
$returnAdditionalFields)
{
$GLOBALS['CampaignManagementProxy']->SetAuthorizationData($GLOBALS['AuthorizationData']);
$GLOBALS['Proxy'] = $GLOBALS['CampaignManagementProxy'];
Expand All @@ -741,13 +744,15 @@ static function GetAdsByAdGroupId(

$request->AdGroupId = $adGroupId;
$request->AdTypes = $adTypes;
$request->ReturnAdditionalFields = $returnAdditionalFields;

return $GLOBALS['CampaignManagementProxy']->GetService()->GetAdsByAdGroupId($request);
}
static function GetAdsByEditorialStatus(
$adGroupId,
$editorialStatus,
$adTypes)
$adTypes,
$returnAdditionalFields)
{
$GLOBALS['CampaignManagementProxy']->SetAuthorizationData($GLOBALS['AuthorizationData']);
$GLOBALS['Proxy'] = $GLOBALS['CampaignManagementProxy'];
Expand All @@ -757,13 +762,15 @@ static function GetAdsByEditorialStatus(
$request->AdGroupId = $adGroupId;
$request->EditorialStatus = $editorialStatus;
$request->AdTypes = $adTypes;
$request->ReturnAdditionalFields = $returnAdditionalFields;

return $GLOBALS['CampaignManagementProxy']->GetService()->GetAdsByEditorialStatus($request);
}
static function GetAdsByIds(
$adGroupId,
$adIds,
$adTypes)
$adTypes,
$returnAdditionalFields)
{
$GLOBALS['CampaignManagementProxy']->SetAuthorizationData($GLOBALS['AuthorizationData']);
$GLOBALS['Proxy'] = $GLOBALS['CampaignManagementProxy'];
Expand All @@ -773,6 +780,7 @@ static function GetAdsByIds(
$request->AdGroupId = $adGroupId;
$request->AdIds = $adIds;
$request->AdTypes = $adTypes;
$request->ReturnAdditionalFields = $returnAdditionalFields;

return $GLOBALS['CampaignManagementProxy']->GetService()->GetAdsByIds($request);
}
Expand Down Expand Up @@ -1368,7 +1376,8 @@ static function UpdateCampaignCriterions(
}
static function UpdateCampaigns(
$accountId,
$campaigns)
$campaigns,
$includeDynamicSearchAdsSource)
{
$GLOBALS['CampaignManagementProxy']->SetAuthorizationData($GLOBALS['AuthorizationData']);
$GLOBALS['Proxy'] = $GLOBALS['CampaignManagementProxy'];
Expand All @@ -1377,6 +1386,7 @@ static function UpdateCampaigns(

$request->AccountId = $accountId;
$request->Campaigns = $campaigns;
$request->IncludeDynamicSearchAdsSource = $includeDynamicSearchAdsSource;

return $GLOBALS['CampaignManagementProxy']->GetService()->UpdateCampaigns($request);
}
Expand Down Expand Up @@ -3347,8 +3357,10 @@ static function OutputExpandedTextAd($dataObject)
self::OutputStatusMessage(sprintf("Path1: %s", $dataObject->Path1));
self::OutputStatusMessage(sprintf("Path2: %s", $dataObject->Path2));
self::OutputStatusMessage(sprintf("Text: %s", $dataObject->Text));
self::OutputStatusMessage(sprintf("TextPart2: %s", $dataObject->TextPart2));
self::OutputStatusMessage(sprintf("TitlePart1: %s", $dataObject->TitlePart1));
self::OutputStatusMessage(sprintf("TitlePart2: %s", $dataObject->TitlePart2));
self::OutputStatusMessage(sprintf("TitlePart3: %s", $dataObject->TitlePart3));
}
self::OutputStatusMessage("* * * End OutputExpandedTextAd * * *");
}
Expand Down Expand Up @@ -5228,6 +5240,29 @@ static function OutputArrayOfCallToAction($valueSets)
}
self::OutputStatusMessage("* * * End OutputArrayOfCallToAction * * *");
}
static function OutputAssetLinkEditorialStatus($valueSet)
{
self::OutputStatusMessage("* * * Begin OutputAssetLinkEditorialStatus * * *");
self::OutputStatusMessage(sprintf("Values in %s", $valueSet->type));
foreach ($valueSet->string as $value)
{
self::OutputStatusMessage($value);
}
self::OutputStatusMessage("* * * End OutputAssetLinkEditorialStatus * * *");
}
static function OutputArrayOfAssetLinkEditorialStatus($valueSets)
{
if(count((array)$valueSets) == 0)
{
return;
}
self::OutputStatusMessage("* * * Begin OutputArrayOfAssetLinkEditorialStatus * * *");
foreach ($valueSets->AssetLinkEditorialStatus as $valueSet)
{
self::OutputAssetLinkEditorialStatus($valueSet);
}
self::OutputStatusMessage("* * * End OutputArrayOfAssetLinkEditorialStatus * * *");
}
static function OutputBudgetLimitType($valueSet)
{
self::OutputStatusMessage("* * * Begin OutputBudgetLimitType * * *");
Expand Down Expand Up @@ -5458,6 +5493,29 @@ static function OutputArrayOfAdGroupStatus($valueSets)
}
self::OutputStatusMessage("* * * End OutputArrayOfAdGroupStatus * * *");
}
static function OutputAdAdditionalField($valueSet)
{
self::OutputStatusMessage("* * * Begin OutputAdAdditionalField * * *");
self::OutputStatusMessage(sprintf("Values in %s", $valueSet->type));
foreach ($valueSet->string as $value)
{
self::OutputStatusMessage($value);
}
self::OutputStatusMessage("* * * End OutputAdAdditionalField * * *");
}
static function OutputArrayOfAdAdditionalField($valueSets)
{
if(count((array)$valueSets) == 0)
{
return;
}
self::OutputStatusMessage("* * * Begin OutputArrayOfAdAdditionalField * * *");
foreach ($valueSets->AdAdditionalField as $valueSet)
{
self::OutputAdAdditionalField($valueSet);
}
self::OutputStatusMessage("* * * End OutputArrayOfAdAdditionalField * * *");
}
static function OutputKeywordEditorialStatus($valueSet)
{
self::OutputStatusMessage("* * * Begin OutputKeywordEditorialStatus * * *");
Expand Down
5 changes: 4 additions & 1 deletion samples/V12/DynamicSearchAds.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@
$campaigns[] = $campaign;

print "AddCampaigns\n";
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns($GLOBALS['AuthorizationData']->AccountId, $campaigns);
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns(
$GLOBALS['AuthorizationData']->AccountId,
$campaigns,
false);
$nillableCampaignIds = $addCampaignsResponse->CampaignIds;
CampaignManagementExampleHelper::OutputArrayOfLong($nillableCampaignIds);
if(isset($addCampaignsResponse->PartialErrors)){
Expand Down
40 changes: 31 additions & 9 deletions samples/V12/KeywordsAds.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Microsoft\BingAds\V12\CampaignManagement\Keyword;
use Microsoft\BingAds\V12\CampaignManagement\Ad;
use Microsoft\BingAds\V12\CampaignManagement\AdType;
use Microsoft\BingAds\V12\CampaignManagement\AdAdditionalField;
use Microsoft\BingAds\V12\CampaignManagement\ExpandedTextAd;
use Microsoft\BingAds\V12\CampaignManagement\Bid;
use Microsoft\BingAds\V12\CampaignManagement\BiddingScheme;
Expand Down Expand Up @@ -262,7 +263,10 @@
// Add the campaign, ad group, keywords, and ads

print "AddCampaigns\n";
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns($GLOBALS['AuthorizationData']->AccountId, $campaigns);
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns(
$GLOBALS['AuthorizationData']->AccountId,
$campaigns,
false);
$nillableCampaignIds = $addCampaignsResponse->CampaignIds;
CampaignManagementExampleHelper::OutputArrayOfLong($nillableCampaignIds);
if(isset($addCampaignsResponse->PartialErrors->BatchError)){
Expand Down Expand Up @@ -412,7 +416,10 @@
$index++;
}

CampaignManagementExampleHelper::UpdateCampaigns($GLOBALS['AuthorizationData']->AccountId, $updateCampaigns);
CampaignManagementExampleHelper::UpdateCampaigns(
$GLOBALS['AuthorizationData']->AccountId,
$updateCampaigns,
false);

$getCampaigns = CampaignManagementExampleHelper::GetCampaignsByIds(
$GLOBALS['AuthorizationData']->AccountId,
Expand Down Expand Up @@ -465,12 +472,23 @@
// As an exercise you can view the results before and after update.

$adTypes = array(AdType::AppInstall, AdType::DynamicSearch, AdType::ExpandedText, AdType::Product, AdType::Text);
$ads = CampaignManagementExampleHelper::GetAdsByAdGroupId($nillableAdGroupIds->long[0], $adTypes);
CampaignManagementExampleHelper::OutputArrayOfAd($ads);
$adAdditionalFields = array(AdAdditionalField::TextPart2, AdAdditionalField::TitlePart3);
$ads = CampaignManagementExampleHelper::GetAdsByAdGroupId(
$nillableAdGroupIds->long[0],
$adTypes,
$adAdditionalFields);
if(isset($ads->Ads)){
CampaignManagementExampleHelper::OutputArrayOfAd($ads->Ads);
}

$updateAdsResponse = CampaignManagementExampleHelper::UpdateAds($nillableAdGroupIds->long[0], $updateAds);
$ads = CampaignManagementExampleHelper::GetAdsByAdGroupId($nillableAdGroupIds->long[0], $adTypes);
CampaignManagementExampleHelper::OutputArrayOfAd($ads);
$ads = CampaignManagementExampleHelper::GetAdsByAdGroupId(
$nillableAdGroupIds->long[0],
$adTypes,
$adAdditionalFields);
if(isset($ads->Ads)){
CampaignManagementExampleHelper::OutputArrayOfAd($ads->Ads);
}

// Here is a simple example that updates the keyword bid to use the ad group bid

Expand All @@ -485,15 +503,19 @@
// As an exercise you can view the results before and after update.

$keywords = CampaignManagementExampleHelper::GetKeywordsByAdGroupId($nillableAdGroupIds->long[0], null);
CampaignManagementExampleHelper::OutputArrayOfKeyword($keywords);
if(isset($keywords->Keywords)){
CampaignManagementExampleHelper::OutputArrayOfKeyword($keywords->Keywords);
}

$updateKeywordsResponse = CampaignManagementExampleHelper::UpdateKeywords(
$nillableAdGroupIds->long[0],
$updateKeywords,
null);
$keywords = CampaignManagementExampleHelper::GetKeywordsByAdGroupId($nillableAdGroupIds->long[0], null);
CampaignManagementExampleHelper::OutputArrayOfKeyword($keywords);

if(isset($keywords->Keywords)){
CampaignManagementExampleHelper::OutputArrayOfKeyword($keywords->Keywords);
}

// As an exercise you can delete the keyword
CampaignManagementExampleHelper::DeleteKeywords($nillableAdGroupIds->long[0], array($nillableKeywordIds->long[1]));

Expand Down
3 changes: 2 additions & 1 deletion samples/V12/Labels.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@

$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns(
$GLOBALS['AuthorizationData']->AccountId,
$campaigns);
$campaigns,
false);
$nillableCampaignIds = $addCampaignsResponse->CampaignIds;
$campaignErrors = $addLabelsResponse->PartialErrors;
print("New Campaign Ids:\n");
Expand Down
5 changes: 4 additions & 1 deletion samples/V12/NegativeKeywords.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@
$campaigns[] = $campaign;

print "AddCampaigns\n";
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns($GLOBALS['AuthorizationData']->AccountId, $campaigns);
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns(
$GLOBALS['AuthorizationData']->AccountId,
$campaigns,
false);
$nillableCampaignIds = $addCampaignsResponse->CampaignIds;
CampaignManagementExampleHelper::OutputArrayOfLong($nillableCampaignIds);
if(isset($addCampaignsResponse->PartialErrors->BatchError)){
Expand Down
5 changes: 4 additions & 1 deletion samples/V12/RemarketingLists.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@
$adGroups[] = $adGroup;

print "AddCampaigns\n";
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns($GLOBALS['AuthorizationData']->AccountId, $campaigns);
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns(
$GLOBALS['AuthorizationData']->AccountId,
$campaigns,
false);
$nillableCampaignIds = $addCampaignsResponse->CampaignIds;
CampaignManagementExampleHelper::OutputArrayOfLong($nillableCampaignIds);
if(isset($addCampaignsResponse->PartialErrors->BatchError)){
Expand Down
5 changes: 4 additions & 1 deletion samples/V12/ShoppingCampaigns.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@
$ads[] = $encodedAd;

print "AddCampaigns\n";
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns($GLOBALS['AuthorizationData']->AccountId, $campaigns);
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns(
$GLOBALS['AuthorizationData']->AccountId,
$campaigns,
false);
$nillableCampaignIds = $addCampaignsResponse->CampaignIds;
CampaignManagementExampleHelper::OutputArrayOfLong($nillableCampaignIds);
if(isset($addCampaignsResponse->PartialErrors->BatchError)){
Expand Down
5 changes: 4 additions & 1 deletion samples/V12/TargetCriterions.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ function GetExampleCampaignIds()
}

print "AddCampaigns\n";
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns($GLOBALS['AuthorizationData']->AccountId, $campaigns);
$addCampaignsResponse = CampaignManagementExampleHelper::AddCampaigns(
$GLOBALS['AuthorizationData']->AccountId,
$campaigns,
false);
$nillableCampaignIds = $addCampaignsResponse->CampaignIds;
CampaignManagementExampleHelper::OutputArrayOfLong($nillableCampaignIds);
if(isset($addCampaignsResponse->PartialErrors->BatchError)){
Expand Down
3 changes: 3 additions & 0 deletions src/V12/Bulk/DownloadEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ final class DownloadEntity

/** Include Ad Group Negative Similar Remarketing List Association records in the download that each represent the association relationship between an ad group and a similar remarketing list exclusion. */
const AdGroupNegativeSimilarRemarketingListAssociations = 'AdGroupNegativeSimilarRemarketingListAssociations';

/** Reserved. */
const Experiments = 'Experiments';
}

}
2 changes: 1 addition & 1 deletion src/V12/Bulk/GetBulkDownloadStatusResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ final class GetBulkDownloadStatusResponse
public $RequestStatus;

/**
* The URL that contains the download data.
* The URL that contains the download data when the RequestStatus value is Completed.
* @var string
*/
public $ResultFileUrl;
Expand Down
6 changes: 6 additions & 0 deletions src/V12/CampaignManagement/AddCampaignsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ final class AddCampaignsRequest
* @var Campaign[]
*/
public $Campaigns;

/**
* Reserved.
* @var boolean
*/
public $IncludeDynamicSearchAdsSource;
}
}
25 changes: 25 additions & 0 deletions src/V12/CampaignManagement/AssetLinkEditorialStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Microsoft\BingAds\V12\CampaignManagement;

{
/**
* Reserved for future use.
* @link https://docs.microsoft.com/en-us/bingads/campaign-management-service/assetlinkeditorialstatus?view=bingads-12 AssetLinkEditorialStatus Value Set
*/
final class AssetLinkEditorialStatus
{
/** Reserved. */
const Active = 'Active';

/** Reserved. */
const Disapproved = 'Disapproved';

/** Reserved. */
const Inactive = 'Inactive';

/** Reserved. */
const ActiveLimited = 'ActiveLimited';
}

}
Loading

0 comments on commit 7f71eae

Please sign in to comment.