#!/usr/bin/python2.2 # # Copyright 2006, Google Inc. All Rights Reserved. ################################################################ # sample code to create an Adsense account through Adsense API # ################################################################ import SOAPpy server = "https://www.google.com" dev_email = "REPLACE WITH DEVELOPER EMAIL" dev_password = "REPLACE WITH DEVELOPER PASSWORD" # Set headers headers = SOAPpy.Types.headerType() headers.developer_email = dev_email headers.developer_password = dev_password headers.client_id = "will be ignored" # Set service connection service = SOAPpy.SOAPProxy( server + "/api/adsense/v2/AccountService", header=headers) # To view xml request/response set service.config.debug = 1 service.config.debug = 0 # Set the parameters login_email = SOAPpy.Types.untypedType("users_address_here@example.com") entity_type = SOAPpy.Types.untypedType("Individual") website_url = SOAPpy.Types.untypedType("http://test.aaa.com") website_locale = SOAPpy.Types.untypedType("en") users_preferred_locale = SOAPpy.Types.untypedType("en_US") email_promotion_preferences = SOAPpy.Types.untypedType("true") syn_service_types = SOAPpy.Types.untypedType("ContentAds") has_accepted_TCs = SOAPpy.Types.untypedType("true") # Create an adsense account, might throw a soap exception # on user input or error upon trying to connect response = service.createAdSenseAccount( login_email, entity_type, website_url, website_locale, users_preferred_locale, email_promotion_preferences, syn_service_types, has_accepted_TCs ) # Print results print "Adsense account creation successful" print "account type :", response["type"] print "syn id :", response["id"]