Class AdWordAdService

Description

AdWords Lib Ad Class

Use this class to work with Google AdWords Ad Service AdService provides operations for accessing, creating and modifying Ads in an AdGroup. Each Ad object is the visual representation of an ad. Each ad group has one or more ads, where an ad can be of many different formats (such as text ad or an image ad). An ad can be in following serving statuses: enabled, disabled, or paused. Only enabled ads will be served; a disabled or paused ad will not be served.

Located in /services/AdWordAdService.inc

AdWordService
   |
   --AdWordAdService
Method Summary
 AdWordAdService AdWordAdService (string $soapToolkit)
 object|false addAds ( $ads, [string $clientEmail = ''], array $newAds)
 object|false checkAds (array $ads, [object AdWordLanguageTarget $languageTarget = ''], [object AdWordGeoTarget $geoTarget = ''], [string $clientEmail = ''])
 object|false findBusinesses (string $name, string $address, string $countryCode, [string $clientEmail = ''])
 object|false getActiveAds (array $adGroupIds, [string $clientEmail = ''])
 object|false getAd (int $adGroupId, int $adId, [string $clientEmail = ''])
 object|false getAdStats (int $adGroupId, int $adIds, int $startDay, int $endDay, [string $clientEmail = ''])
 object|false getAllAds (array $adGroupIds, [string $clientEmail = ''])
 object|false getMyBusinesses ([string $clientEmail = ''])
 object|false getMyVideos ([string $clientEmail = ''])
 bool updateAds (array $ads, [string $clientEmail = ''])
Methods

AdWordAdService Constructor. It takes one parameter - name of a supported by AdWords Lib SOAP toolkit

Example:

  1.  <?php
  2.  ?>
Please use defined constants for supported by AdWords Lib toolkit names

AdWordAdService AdWordAdService (string $soapToolkit)
  • string $soapToolkit: name of a supported by AdWords Lib SOAP Toolkit

Make a batch of new Ads.

The adGroupId field of the Ad indicates which AdGroup to add the Ad to. The adGroupId field is required, and the indicated AdGroup must exist already. The Ad's id and disapproved fields are set by the AdService -- if you fill them in they will be ignored. By default, Ads are enabled and will be served as soon as they are created. You can set the status field on the ad to either paused or disabled to prevent the ad from being active.

Example:

  1.  <?php
  2.  $adService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  3.  //$newAds is an array of objects of class AdWordAd or any of its descendants
  4.  $response $adService->addAds($newAds);
  5.  if ($response === false// if an error appears
  6.          $errr $adService->getLastError()//get error object
  7.          echo $errr->toString()//output error
  8.          exit();
  9.  }
  10.  //$response is an array of objects of class AdWordAd
  11.  ?>

object|false addAds ( $ads, [string $clientEmail = ''], array $newAds)
  • array $newAds: array of objects of class AdWordAd
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account
  • $ads

Check a batch of Ads for policy errors.

The number of Ads in the batch is limited to the maximum number of Ads per adgroup.

Example:

  1.  <?php
  2.  $adService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  3.  //$ads is an array of objects of class AdWordAd
  4.  //$languageTarget is an object of class AdWordLanguageTarget
  5.  //$geoTarget is an object of class AdWordGeoTarget
  6.  $response $adService->checkAds($ads$languageTarget$geoTarget);
  7.  if ($response === false// if an error appears
  8.          $errr $adService->getLastError()//get error object
  9.          echo $errr->toString()//output error
  10.          exit();
  11.  }
  12.  //$response is an array of objects of class ApiError which hold a list of policy errors
  13.  ?>

object|false checkAds (array $ads, [object AdWordLanguageTarget $languageTarget = ''], [object AdWordGeoTarget $geoTarget = ''], [string $clientEmail = ''])

Searches for businesses with similar attributes.

This call is similar to querying Google Local Search. All parameters are required.

Example:

  1.  <?php
  2.  $adService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  3.  $response $adService->findBusinesses($name$address$countryCode);
  4.  if ($response === false// if an error appears
  5.          $errr $adService->getLastError()//get error object
  6.          echo $errr->toString()//output error
  7.          exit();
  8.  }
  9.  //$response is an array of objects of class AdWordBusiness
  10.  ?>

object|false findBusinesses (string $name, string $address, string $countryCode, [string $clientEmail = ''])
  • string $name: Name of the business. Must not be null.
  • string $address: Location of the business. Format is free form. Examples: "Mountain View, CA" or "1600 Amphitheatre Pkwy, Mountain View, CA". Must not be null.
  • string $countryCode: Two letter country code of the business address. Must not be null.
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Return all active Ads associated with the list of AdGroup ids specified.

Example:

  1.  <?php
  2.  $adService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  3.  $response $adService->getActiveAds($adGroupIds);
  4.  if ($response === false// if an error appears
  5.          $errr $adService->getLastError()//get error object
  6.          echo $errr->toString()//output error
  7.          exit();
  8.  }
  9.  //$response is an array of objects of class AdWordAd
  10.  ?>

object|false getActiveAds (array $adGroupIds, [string $clientEmail = ''])
  • array $adGroupIds: An array of AdGroup Ids that own the Ads
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Return information about one Ad.

Example:

  1.  <?php
  2.  $adService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  3.  $response $adService->getAd($adGroupId$adId);
  4.  if ($response === false// if an error appears
  5.          $errr $adService->getLastError()//get error object
  6.          echo $errr->toString()//output error
  7.          exit();
  8.  }
  9.  //$response is an array of objects of class AdWordAd
  10.  ?>

object|false getAd (int $adGroupId, int $adId, [string $clientEmail = ''])
  • int $adGroupId: The ID of the AdGroup owning the Ad
  • int $adId: The ID of the Ad
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Get statistics for a list of ads in an ad group.

The time granularity is one day.

Example:

  1.  <?php
  2.  $adService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  3.  $response $adService->getAdStats($adGroupId$adIds$startDay$endDaytrue);
  4.  if ($response === false// if an error appears
  5.          $errr $adService->getLastError()//get error object
  6.          echo $errr->toString()//output error
  7.          exit();
  8.  }
  9.  //$response is an array of objects of class AdWordStatsRecord
  10.  ?>

object|false getAdStats (int $adGroupId, int $adIds, int $startDay, int $endDay, [string $clientEmail = ''])
  • int $adGroupId: The ID of the AdGroup owning the Ad
  • int $adIds: The ads to query
  • int $startDay: The starting day of the period for which statistics are to be collected (xsd:date)
  • int $endDay: The ending day of the period for which statistics are to be collected, inclusive (xsd:date)
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Return all Ads (enabled, disabled, or paused) associated with the list of AdGroup ids specified.

Example:

  1.  <?php
  2.  $adService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  3.  $response $adService->getAllAds($adGroupIds);
  4.  if ($response === false// if an error appears
  5.          $errr $adService->getLastError()//get error object
  6.          echo $errr->toString()//output error
  7.          exit();
  8.  }
  9.  //$response is an array of objects of class AdWordAd
  10.  ?>

object|false getAllAds (array $adGroupIds, [string $clientEmail = ''])
  • array $adGroupIds: An array of AdGroup Ids that own the Ads
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Returns the list of businesses registered to the user in the Local Business Center.

The user is determined by the clientEmail header if it is specified. Otherwise, the email header is used instead.

Example:

  1.  <?php
  2.  $adService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  3.  $response $adService->getMyBusinesses();
  4.  if ($response === false// if an error appears
  5.          $errr $adService->getLastError()//get error object
  6.          echo $errr->toString()//output error
  7.          exit();
  8.  }
  9.  //$response is an array of objects of class AdWordBusiness
  10.  ?>

object|false getMyBusinesses ([string $clientEmail = ''])
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Returns a list of all videos stored under the users account.

The user is determined by the clientEmail if specified. Otherwise, the email header is used.

Example:

  1.  <?php
  2.  $adService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  3.  $response $adService->getMyVideos();
  4.  if ($response === false// if an error appears
  5.          $errr $adService->getLastError()//get error object
  6.          echo $errr->toString()//output error
  7.          exit();
  8.  }
  9.  //$response is an array of objects of class AdWordVideo
  10.  ?>

object|false getMyVideos ([string $clientEmail = ''])
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Update a batch of ads.

Use the id field of the ad to indicate which ad to update. Currently only the status field is updateable, all other fields will be ignored.

Example:

  1.  <?php
  2.  $criterionService new AdWordAdService(ADWORD_SOAP_TOOLKIT_NUSOAP);
  3.  $criterionService->setAccount($myEmail$myPass$myUserAgent$myDeveloperToken$myApplicationToken);
  4.  //$ad1, $ad2 is an object of class AdWordAd or any of its descendants
  5.  $ads array($ad1$ad2);
  6.  $response $criterionService->updateAds($ads);
  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.  //$response == true
  13.  ?>

bool updateAds (array $ads, [string $clientEmail = ''])
  • array $ads: array of objects of class AdWordAd
  • string $clientEmail: provide the clientEmail when you want to edit a client's account rather than your own account

Inherited Methods

Inherited From AdWordService

 AdWordService::AdWordService()
 AdWordService::callService()
 AdWordService::getAccount()
 AdWordService::getClientCustomerId()
 AdWordService::getClientEmail()
 AdWordService::getLastError()
 AdWordService::getResponseHeaders()
 AdWordService::setAccount()
 AdWordService::setClientCustomerId()
 AdWordService::setClientEmail()

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