$ads[1]->enc_value->Title = "Women's Super Shoe Sale"; $ads[2]->enc_value->Title = "Women's Red Shoe Sale"; $ads[3]->enc_value->Title = ""; $ads[4]->enc_value->Title = "Women's Super Shoe Sale"; // Add the campaign, ad group, keywords, and ads $campaignIds = AddCampaigns($proxy, $AccountId, $campaigns); $adGroupIds = AddAdGroups($proxy, $campaignIds[0], $adGroups); $addKeywordsResponse = AddKeywords($proxy, $adGroupIds[0], $keywords); $keywordIds = $addKeywordsResponse->KeywordIds->long; $keywordErrors = $addKeywordsResponse->PartialErrors->BatchError; $addAdsResponse = AddAds($proxy, $adGroupIds[0], $ads); $adIds = $addAdsResponse->AdIds->long; $adErrors = $addAdsResponse->PartialErrors->BatchError; // Print the new assigned campaign and ad group identifiers PrintCampaignIdentifiers($campaignIds); PrintAdGroupIdentifiers($adGroupIds); // Print the new assigned keyword and ad identifiers, as well as any partial errors PrintKeywordResults($keywords, $keywordIds, $keywordErrors); PrintAdResults($ads, $adIds, $adErrors); // Delete the campaign, ad group, keyword, and ad that were previously added. // You should remove this line if you want to view the added entities in the // Bing Ads web application or another tool. DeleteCampaigns($proxy, $AccountId, array($campaignIds[0])); printf("Deleted CampaignId %d\n\n", $campaignIds[0]); } catch (SoapFault $e) { // Output the last request/response. print "\nLast SOAP request/response:\n"; print $proxy->GetWsdl() . "\n"; print $proxy->GetService()->__getLastRequest() . "\n"; print $proxy->GetService()->__getLastResponse() . "\n"; // Campaign Management service operations can throw AdApiFaultDetail.
$ReferenceId = -1; // Campaign Management WSDL $wsdl = "https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V10/CampaignManagementService.svc?singleWsdl"; $ids = null; try { $proxy = ClientProxy::ConstructWithAccountAndCustomerId($wsdl, $UserName, $Password, $DeveloperToken, $AccountId, $CustomerId, null); $stores = GetStores($proxy); if (!isset($stores)) { printf("Customer %d does not have any regeistered BMC stores.\n\n", $CustomerId); return; } // Create a Bing Shopping campaign using the ID of the first store in the list. $campaignIds = AddCampaigns($proxy, $AccountId, $stores[0]->Id); PrintCampaignIdentifiers($campaignIds->long); $adGroupIds = AddAdGroups($proxy, $campaignIds->long[0]); PrintAdGroupIdentifiers($adGroupIds->long); $response = AddAds($proxy, $adGroupIds->long[0]); PrintAdIdentifiers($response->AdIds->long, $response->PartialErrors); // Add criterion to the campaign. The criterion is used to limit the campaign to a subset of // your product catalog. $addCriterionResponse = AddCampaignCriterion($proxy, $campaignIds->long[0]); PrintCampaignCriterionIdentifiers($addCriterionResponse->CampaignCriterionIds->long, $addCriterionResponse->NestedPartialErrors); AddAndUpdateAdGroupCriterion($proxy, $AccountId, $PartitionActions, $adGroupIds->long[0]); $applyPartitionActionsResponse = AddBranchAndLeafCriterion($proxy, $AccountId, $PartitionActions, $adGroupIds->long[0]); $rootId = $applyPartitionActionsResponse->AdGroupCriterionIds->long[1]; $electronicsCriterionId = $applyPartitionActionsResponse->AdGroupCriterionIds->long[8]; UpdateBranchAndLeafCriterion($proxy, $PartitionActions, $AccountId, $adGroupIds->long[0], $rootId, $electronicsCriterionId); // Delete the campaign from the account. //DeleteCampaigns($proxy, $AccountId, $campaignIds->long); //printf("Deleted CampaignId %d\n", $campaignIds->long[0]); // Added just the one } catch (SoapFault $e) {