Class AdWordService

Description

AdWords Lib AdWordService

Base class for all AdWords Services Classes.

  • copyright: Mirchev Ideas Ltd. © 2003, 2004, 2005

Located in /services/AdWordService.inc


	
			
Direct descendents
Class Description
 class AdWordAccountService AdWords Lib Account Service Class
 class AdWordAdGroupService AdWords Lib AdGroup Class
 class AdWordCampaignService AdWords Lib Campaign Service Class
 class AdWordCriterionService AdWords Lib Criterion Class
 class AdWordInfoService AdWords Lib Info Service Class
 class AdWordAdService AdWords Lib Ad Class
 class AdWordReportService AdWords Lib Report Service Class
 class AdWordTrafficEstimatorService AdWords Lib Traffic Estimator Service Class
 class AdWordKeywordToolService AdWords Lib KeywordToolService Class
 class AdWordSiteSuggestionService AdWords Lib Site Suggestion Service Class
Method Summary
 AdWordService AdWordService (string $soapToolkit, string $url)
 mixed callService (string $command, string $paramsxml, [string $clientEmail = ''], [boolean $expectsArray = false])
 array getAccount ()
 string getClientEmail ()
 object|null getLastError ()
 void setAccount (string $accountEmail, string $accountPass, string $accountUserAgent, string $accountDeveloperToken, string $accountApplicationToken)
 void setClientCustomerId (string $clientCustomerId)
 void setClientEmail (string $clientEmail)
Methods

AdWordService Constructor. It takes two parameters - name of a supported by AdWords Lib SOAP toolkit and a service URL

Example:

  1.  <?php
  2.  $obj new AdWordService(ADWORD_SOAP_TOOLKIT_NUSOAPADWORD_KEYWORD_SERVICE_URL);
  3.  ?>
Please use defined constants for supported by AdWords Lib toolkit names and service URLs

AdWordService AdWordService (string $soapToolkit, string $url)
  • string $soapToolkit: name of a supported by AdWords Lib SOAP Toolkit
  • string $url: the URL for this service

Call a Google AdWords service

Example:

  1.  <?php
  2.  $obj new AdWordService(ADWORD_SOAP_TOOLKIT_NUSOAPADWORD_KEYWORD_SERVICE_URL);
  3.  $obj->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  $result $obj->callService($command$paramsxml);
  5.  // $result holds response string from Google AdWords service or false on error
  6.  ?>

  • return: response string from Google AdWords service or false on error
  • see: AdWordError
mixed callService (string $command, string $paramsxml, [string $clientEmail = ''], [boolean $expectsArray = false])
  • string $command: Google AdWords service command
  • string $paramsxml: Google AdWords service command parameters in XML format
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account
  • boolean $expectsArray: if true the return should be array of objects

Returns an array with Google AdWords account that was set by AdWordService::setAccount() function

Example:

  1.  <?php
  2.  $obj new AdWordService(ADWORD_SOAP_TOOLKIT_NUSOAPADWORD_KEYWORD_SERVICE_URL);
  3.  $account $obj->getAccount()// $account is an empty array
  4.  $obj->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  5.  ...
  6.  $account $obj->getAccount();
  7.  //$account is an array with the account values set by AdWordService::setAccount() function
  8.  ?>

array getAccount ()

Returns clientCustomerId that was set by AdWordService::setClientCustomerId() function

If no clientCustomerId was set, returns an empty string.

Example:

  1.  <?php
  2.  $obj new AdWordService(ADWORD_SOAP_TOOLKIT_NUSOAPADWORD_KEYWORD_SERVICE_URL);
  3.  $obj->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  $string $obj->getClientCustomerId()// $string == ''
  5.  $obj->setClientCustomerId($clientCustomerId);
  6.  ...
  7.  $string $obj->getClientCustomerId()// $string == $clientCustomerId
  8.  ?>

string getClientCustomerId ()

Returns clientEmail that was set by AdWordService::setClientEmail() function

If no clientEmail was set, returns an empty string.

Example:

  1.  <?php
  2.  $obj new AdWordService(ADWORD_SOAP_TOOLKIT_NUSOAPADWORD_KEYWORD_SERVICE_URL);
  3.  $obj->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  $string $obj->getClientEmail()// $string == ''
  5.  $obj->setClientEmail($clientEmail);
  6.  ...
  7.  $string $obj->getClientEmail()// $string == $clientEmail
  8.  ?>

string getClientEmail ()

Returns last error. If there is no error returns NULL

Example:

  1.  <?php
  2.  $obj new AdWordService(ADWORD_SOAP_TOOLKIT_NUSOAPADWORD_KEYWORD_SERVICE_URL);
  3.  $obj->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  $error $obj->getLastError()// $error is NULL
  5.  ...
  6.  $result $obj->callService($command$sameWrongParam);
  7.  if ($result === false)
  8.          $error $obj->getLastError()// $error is an object of class AdWordError
  9.  ?>

object|null getLastError ()

Returns an array with AdWords response headers from the last operation.

The headers include requestId, responseTime, operations and units. Units contains the amount of quota used.

Example:

  1.  <?php
  2.  $keywordService new AdWordKeywordService(ADWORD_SOAP_TOOLKIT_NUSOAP);
  3.  $keywordService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  
  5.  # $newKeyword is an object of class AdWordKeyword
  6.  $response $keywordService->addKeyword($newKeyword);
  7.  if ($response === false// if an error appears
  8.          $errr $classKW->getLastError()//get error object
  9.          echo $errr->toString()//output error
  10.          exit();
  11.  }
  12.  
  13.  # print the response headers
  14.  $responseHeaders $keywordService->getResponseHeaders();
  15.  echo 'Request ID: ' $responseHeaders['requestId''<br>';
  16.  echo 'Response Time: ' $responseHeaders['responseTime''<br>';
  17.  echo 'Operations: ' $responseHeaders['operations''<br>';
  18.  echo 'Units: ' $responseHeaders['units''<br>';
  19.  ?>

  • return: the headers
array getResponseHeaders ()

Sets a google AdWords account to work with

Example:

  1.  <?php
  2.  $obj new AdWordService(ADWORD_SOAP_TOOLKIT_NUSOAPADWORD_KEYWORD_SERVICE_URL);
  3.  $obj->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  ?>

void setAccount (string $accountEmail, string $accountPass, string $accountUserAgent, string $accountDeveloperToken, string $accountApplicationToken)
  • string $accountEmail: email address for the AdWords account being accessed.
  • string $accountPass: password for the AdWords account being accessed.
  • string $accountUserAgent: an arbitrary string that identifies the customer sending the request.
  • string $accountDeveloperToken: a unique string that identifies you as an authorized developer for the AdWords API. An example developer token string is ABcdeFGH93KL-NOPQ_STUv.
  • string $accountApplicationToken: a string that identifies an application as one authorized to call the AdWords API web services. If your application calls another application, use the application token for the one that actually sends the request.

Sets clientCustomerId to be used for a service

Provide the clientCustomerId when you want to edit a client's account rather than your own account. The client's customerId set by this function must be managed by account set by AdWordService::setAccount() function

Example:

  1.  <?php
  2.  $obj new AdWordService(ADWORD_SOAP_TOOLKIT_NUSOAPADWORD_KEYWORD_SERVICE_URL);
  3.  $obj->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  // you can set a client's customerId and work with their account
  5.  $obj->setClientCustomerId($clientCustomerId);
  6.  $result $obj->callService($command$paramsxml);
  7.  //you can still use same object to manage another client account
  8.  $result $obj->callService($command$paramsxml$otherClientEmail);
  9.  ?>

void setClientCustomerId (string $clientCustomerId)
  • string $clientCustomerId: a client's customer id which account you want to edit

Sets clientEmail to be used for a service

Provide the clientEmail when you want to edit a client's account rather than your own account. The client's email set by this function must be managed by account set by AdWordService::setAccount() function

Example:

  1.  <?php
  2.  $obj new AdWordService(ADWORD_SOAP_TOOLKIT_NUSOAPADWORD_KEYWORD_SERVICE_URL);
  3.  $obj->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  // you can call a service command for a client
  5.  $result $obj->callService($command$paramsxml$clientEmail);
  6.  // or you can set a client's email and work with their account
  7.  $obj->setClientEmail($clientEmail);
  8.  $result $obj->callService($command$paramsxml);
  9.  //you can still use same object to manage another client account
  10.  $result $obj->callService($command$paramsxml$otherClientEmail);
  11.  ?>

void setClientEmail (string $clientEmail)
  • string $clientEmail: a client's email which account you want to edit

Documentation generated on Mon, 10 Sep 2007 15:07:27 +0300 by phpDocumentor 1.3.2