This post confirms my ownership of the site and that this site adheres to Google AdSense program policies and Terms and Conditions

Wednesday, March 10, 2010

Associate Account using 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 = "REPLACE WITH DEVELOPER EMAIL";

$password = "REPLACE WITH DEVELOPER PASSWORD";

$client_id = "NOT RELEVANT";



$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 = "users_address_here@example.com";

$param .= "USERS POSTAL CODE";

$param .= "USERS PHONE NUMBER";

$param .= "SITE TO BE ASSOCIATED WITH THIS PUBLISHER";

$param .= "" . $param . "";



// 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);



?>

source: http://code.google.com/p/google-sensapility/source/browse/trunk/samplecode/v3/AssociateAccount.php?r=97&spec=svn105

No comments:

Post a Comment