// 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 = "
$password = "
$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 = "
$param .= "
$param .= "
$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