My favorites | Sign in
Google
                
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php

// Copyright 2005, Google Inc. All rights reserved.

/**
* sample code to create an Adsense account through Adsense API
*/

require_once('lib/nusoap.php');
require_once('common.php');

$server = 'https://sandbox.google.com';
// Comment out the line above and uncomment the line below to use
// the production API server
// $server = 'https://www.google.com';
$namespace = 'http://www.google.com/api/adsense/v3';

// Set up the authentication headers
$email = "<developer_email>REPLACE WITH DEVELOPER EMAIL</developer_email>";
$password = "<developer_password>REPLACE WITH DEVELOPER PASSWORD</developer_password>";
$client_id = "<client_id>NOT RELEVANT</client_id>";

$header = $email . $password . $client_id;

// creating soap client
$wsdl = $server . '/api/adsense/v3/AccountService?wsdl';
$client = new soapclient($wsdl, true);
$err = $client->getError();
if ($err) {
showSoapClientError($err);
return;
}
$client->soap_defencoding = 'UTF-8';

// Set the headers; they are needed for authentication
$client->setHeaders($header);
if ($client->fault) {
showMyErrors($client);
return;
}
$err = $client->getError();
if ($err) {
showSoapClientError($err);
return;
}

// setting the parameters
$param = "<loginEmail>users_address_here@example.com</loginEmail>";
$param .= "<entityType><value>Individual</value></entityType>";
$param .= "<websiteUrl>http://test.aaa.com</websiteUrl>";
$param .= "<websiteLocale>en</websiteLocale>";
$param .= "<usersPreferredLocale>en_US</usersPreferredLocale>";
$param .= "<emailPromotionPreferences>true</emailPromotionPreferences>";
$param .= "<synServiceTypes><value>ContentAds</value></synServiceTypes>";
$param .= "<developerUrl>code.google.com</developerUrl>";
$param = "<ns1:createAccount xmlns:ns1=\"$namespace\">" . $param . "</ns1:createAccount>";

// invoke web service
showCall('createAccount', $param);
$response = $client->call('createAccount', $param, $namespace);
if ($client->fault) {
showMyErrors($client);
return;
}
$err = $client->getError();
if ($err) {
showSoapClientError($err);
return;
}

// get back the response
$response = $response['return'];
showCreatedPublisher($response);

// showing the soap
showRequestResponse($client);

?>
Show details Hide details

Change log

r97 by api.wes on Jan 23, 2009   Diff
Updated AssociateAccount.php to
concatenate params properly.  Updated
spacing in other files.
Go to: 
Project members, sign in to write a code review

Older revisions

r95 by api.wes on Aug 19, 2008   Diff
created v3 subdir in samplecode.
r94 by api.wes on Aug 19, 2008   Diff
Added samplecode to project.
All revisions of this file

File info

Size: 2218 bytes, 78 lines

File properties

svn:executable
*