My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python2.2
#
# Copyright 2006, Google Inc. All Rights Reserved.

###################################################################
# sample code to associate an Adsense account through Adsense API #
###################################################################

import SOAPpy

server = "https://sandbox.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/v3/AccountService",
namespace="http://www.google.com/api/adsense/v3",
header=headers)
# To view xml request/response set service.config.debug = 1
service.config.debug = 0

# Set the parameters
login_email = SOAPpy.Types.untypedType(name="loginEmail",
data="user_address_here@example.com")
postal_code = SOAPpy.Types.untypedType(name="postalCode",data="")
phone = SOAPpy.Types.untypedType(name="phone",data="")
developer_url = SOAPpy.Types.untypedType(name="developerUrl",
data="code.google.com")

try:
response = service.associateAccount(
login_email,
postal_code,
phone,
developer_url
)
except SOAPpy.Types.faultType, fault:
print "Fault!"
print " trigger :",fault['detail']['AdSenseApiExceptionFault']['AdSenseApiException']['trigger']
print " message :",fault['detail']['AdSenseApiExceptionFault']['AdSenseApiException']['message']
print " code :",fault['detail']['AdSenseApiExceptionFault']['AdSenseApiException']['code']
exit(1)

# Print results
print "Adsense account association successful"
if type(response)==list:
for i in response:
print "account type :",i['type']['value']
print " syn id :",i['id']
else:
print "account type :",response['type']['value']
print " syn id :",response['id']

Change log

r4 by adsensea...@google.com on Nov 6, 2008   Diff
Updated developerUrl
Go to: 
Project members, sign in to write a code review

Older revisions

r3 by adsensea...@google.com on Jun 25, 2008   Diff
wes - added samplecode subdir
r2 by adsensea...@google.com on Jun 25, 2008   Diff
wes - Initial checkin.
All revisions of this file

File info

Size: 2063 bytes, 61 lines
Powered by Google Project Hosting