// Copyright 2005 Google Inc. All rights reserved. using System; using System.Net; using System.Web; using System.Xml; /** * Sample code to create an Adsense account through Adsense API */ namespace AdSenseApi { public class CreateAccount { public static void MainCreateAccount() { try { // initialize service serverAccountService.AccountServiceService service = new serverAccountService.AccountServiceService(); // set the headers string developerEmail = "REPLACE WITH DEVELOPER'S EMAIL"; string developerPassword = "REPLACE WITH DEVELOPER'S PASSWORD"; string clientId = "not_important"; service.developer_emailValue = new serverAccountService.developer_email(); service.developer_emailValue.Text = new string[] { developerEmail }; service.developer_passwordValue = new serverAccountService.developer_password(); service.developer_passwordValue.Text = new string[] { developerPassword }; service.client_idValue = new serverAccountService.client_id(); service.client_idValue.Text = new string[] { clientId }; // creating an adsense account serverAccountService.SyndicationService_Data[] result = service.createAdSenseAccount( "REPLACE WITH CLIENT'S EMAIL", // client email "Individual", // entity type "http://test.aaa.com", // website url "en", // website locale "en_US", // users preferred locale true, // email promotion preferences new string[] {"ContentAds"}, // syn service types true // has accepted TCs ); // displays the results Console.WriteLine("Adsense account creation successful"); Console.WriteLine("account type {0}", result[0].type); Console.WriteLine("syn id {0}", result[0].id); } catch (System.Web.Services.Protocols.SoapException e) { // displays errors Console.WriteLine("Account creation failed"); Console.WriteLine("message : {0}", e.Message); Console.WriteLine("source : {0}", e.Source); Console.WriteLine("stacktrace : {0}", e.StackTrace); } } } }