Microsoft Advertising API
A Microsoft API that provides programmatic access to Microsoft Advertising to manage large campaigns or to integrate your marketing with other in-house systems.
424 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to set the bidding scheme when adding a campaign. Here is a sample script:
$authentication = (new OAuthWebAuthCodeGrant())
->withEnvironment(ApiEnvironment::Production)
->withClientId($clientId)
->withClientSecret($clientSecret);
$authorizationData = (new AuthorizationData())
->withAuthentication($authentication)
->withDeveloperToken($developerToken)
->withAccountId($advertiserAccountId);
$authorizationData->Authentication->withOAuthTokens($oAuthTokens)
$campaign = new Campaign();
$campaign->Name = 'test name';
$campaign->BudgetType = BudgetLimitType::DailyBudgetStandard;
$campaign->DailyBudget = 5;
$campaign->Languages = ['English'];
$campaign->TimeZone = 'EasternTimeUSCanada';
$campaign->BiddingScheme = new MaxClicksBiddingScheme();
$campaign->BiddingScheme->MaxCpc = new Bid();
$campaign->BiddingScheme->MaxCpc->Amount = 0.05;
$request = new AddCampaignsRequest();
$request->AccountId = $advertiserAccountId;
$request->Campaigns = [$campaign];
$proxy = new ServiceClient(
ServiceClientType::CampaignManagementVersion13,
$authorizationData,
ApiEnvironment::Production
);
$proxy->GetService()->AddCampaigns($request);
Here is the response I receive:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><s:Fault><faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:InternalServiceFault</faultcode><faultstring xml:lang="en-US">The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.</faultstring></s:Fault></s:Body></s:Envelope>
Any guidance/suggestions are appreciated.
I believe I found the solution. The code for setting the BiddingScheme needed to be like this:
$biddingScheme = new MaxClicksBiddingScheme();
$biddingScheme->MaxCpc = new Bid();
$biddingScheme->MaxCpc->Amount = $data['bid'];
$campaign->BiddingScheme = new SoapVar(
$biddingScheme,
SOAP_ENC_OBJECT,
'MaxClicksBiddingScheme',
$proxy->GetNamespace()
);