2014-10-26 37 views

回答

0
// For Customer managment use the wsdl "https://clientcenter.api.bingads.microsoft.com/Api/CustomerManagement/v9/CustomerManagementService.svc?singleWsdl"   


// Include files from bing client lib here - Or better yet - use composer to autoload - 

      use BingAds\Proxy\ClientProxy; 
      use BingAds\CustomerManagement\Address; 
      use BingAds\CustomerManagement\Customer; 
      use BingAds\CustomerManagement\Industry; 
      use BingAds\CustomerManagement\LanguageType; 
      use BingAds\CustomerManagement\AdvertiserAccount; 
      use BingAds\CustomerManagement\Account; 
      use BingAds\CustomerManagement\CurrencyType; 
      use BingAds\CustomerManagement\SignupCustomerRequest; 
      use BingAds\CustomerManagement\AccountType; 


     // you should download the client lib - then should be able to do like so - 
     // i assume that you have developer token, and access token already for re seller account already ... 

    // also NOTE the soap Var advertiser account - or this won't work - you will get abstract class error ... 

     // Disable WSDL caching. 

     ini_set("soap.wsdl_cache_enabled", "0"); 
     ini_set("soap.wsdl_cache_ttl", "0"); 

     // Specify your credentials. 

     $UserName = "<UserNameGoesHere>"; 
     $Password = "<PasswordGoesHere>"; 
     $DeveloperToken = "DeveloperTokenGoesHere>"; 
     $AccountId = <AccountIdGoesHere>; 


     $proxy = ClientProxy::ConstructWithAccountAndCustomerId($wsdl, $UserName, $Password, $DeveloperToken, $AccountId, null, null); 



       $address = new Address(); 
       $address->CountryCode = 'US'; 
       $address->City = 'Some CIty'; 
       $address->Line1 = 'Some Address'; 
       $address->PostalCode = 60010; 
       $address->StateOrProvince = 'IL'; 

       // create customer 
       $customer = new Customer(); 
       $customer->CustomerAddress = $address; 
       $customer->Industry = Industry::Automotive; 
       $customer->MarketCountry = 'US'; 
       $customer->MarketLanguage = LanguageType::English; 
       $customer->Name = 'No Account'; 


       // create advertiser 
       $advertiseAccount = new AdvertiserAccount(); 
       $advertiseAccount->AccountType = AccountType::Advertiser; 
       $advertiseAccount->Type = CurrencyType::USDollar; 
       $advertiseAccount->CurrencyType = CurrencyType::USDollar; 
       $advertiseAccount->Name ='No Account'; 
       $advertiseAccount->PaymentMethodType = NULL; 


       $request = new SignupCustomerRequest(); 
       $request->Customer = $customer; 
       $request->Account = new \soapVar($advertiseAccount, SOAP_ENC_OBJECT, 'AdvertiserAccount', $proxy->getNamespace() . '/Entities'); 
       $request->ParentCustomerId = \Models\Bingads\User\BingAuth::CUSTOMER_ID_RS; 
       $request->ApplicationScope = ApplicationType::Advertiser; 

       try{ 
        $response = $proxy->GetService()->SignupCustomer($request); 
       }catch(\Exception $e){ 
        error_log($e->getMessage()); 
       } 

       return $response; 
+0

很抱歉的縮進 - 堆棧溢出是有點怪 – ratiorick 2015-05-05 19:15:53

+0

https://github.com/CPCStrategy/bing-ads-sdk-php這裏是回購,如果你想使用的作曲家自動加載此。 – ratiorick 2015-05-05 19:17:06