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
62
63
64
65
66
67
68
69
70
71
72
73
74
<?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 parameter
$param = "<loginEmail>users_address_here@example.com</loginEmail>";
$param .= "<postalCode>USERS POSTAL CODE</postalCode>";
$param .= "<phone>USERS PHONE NUMBER</phone>";
$param .= "<developerUrl>SITE TO BE ASSOCIATED WITH THIS PUBLISHER</developerUrl>";
$param = "<ns1:associateAccount xmlns:ns1=\"$namespace\">" . $param . "</ns1:associateAccount>";

// invoke web service
showCall('associateAccount', $param);
$response = $client->call('associateAccount', $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);

?>

Change log

r99 by api.wes on Mar 24, 2009   Diff
Fixed issue with SOAP payload.
Go to: 
Project members, sign in to write a code review

Older revisions

r98 by api.wes on Jan 27, 2009   Diff
postalCode, not postcalCode...
r97 by api.wes on Jan 23, 2009   Diff
Updated AssociateAccount.php to
concatenate params properly.  Updated
spacing in other files.
r95 by api.wes on Aug 19, 2008   Diff
created v3 subdir in samplecode.
All revisions of this file

File info

Size: 1978 bytes, 74 lines

File properties

svn:executable
*
Powered by Google Project Hosting