use BingAds\v10\CampaignManagement\CustomParameter; // Specify the BingAds\Proxy objects that will be used. use BingAds\Proxy\ClientProxy; // Disable WSDL caching. ini_set("soap.wsdl_cache_enabled", "0"); ini_set("soap.wsdl_cache_ttl", "0"); // Specify your credentials. $UserName = "******"; $Password = "******"; $DeveloperToken = "<DeveloperTokenGoesHere>"; $CustomerId = "<CustomerIdGoesHere>"; $AccountId = "<AccountIdGoesHere>"; // Campaign Management WSDL $wsdl = "https://campaign.api.bingads.microsoft.com/Api/Advertiser/CampaignManagement/V10/CampaignManagementService.svc?singleWsdl"; try { $proxy = ClientProxy::ConstructWithAccountAndCustomerId($wsdl, $UserName, $Password, $DeveloperToken, $AccountId, null, null); // Specify one or more campaigns. $campaigns = array(); $campaign = new Campaign(); $campaign->Name = "Winter Clothing " . $_SERVER['REQUEST_TIME']; $campaign->Description = "Winter clothing line."; $campaign->BudgetType = BudgetLimitType::MonthlyBudgetSpendUntilDepleted; $campaign->MonthlyBudget = 1000.0; $campaign->TimeZone = "PacificTimeUSCanadaTijuana"; $campaign->DaylightSaving = true; // Used with FinalUrls shown in the ads that we will add below. $campaign->TrackingUrlTemplate = "http://tracker.example.com/?season={_season}&promocode={_promocode}&u={lpurl}"; $campaigns[] = $campaign; // Specify one or more ad groups. $adGroups = array(); $endDate = new Date();
function GetCampaignsByAccountId($customerId, $accountId) { $GLOBALS['campaignProxy'] = ClientProxy::ConstructWithAccountAndCustomerId($GLOBALS['campaignWsdl'], $GLOBALS['UserName'], $GLOBALS['Password'], $GLOBALS['DeveloperToken'], $accountId, $customerId, null); $GLOBALS['proxy'] = $GLOBALS['campaignProxy']; $request = new GetCampaignsByAccountIdRequest(); $request->AccountId = $accountId; return $GLOBALS['campaignProxy']->GetService()->GetCampaignsByAccountId($request)->Campaigns; }