We will release PHP samples in V5 to MSDN by May 2008. In the interim, we'll use this site to release PHP samples in V5.
Ad groups are submitted for approval by calling the SubmitAdGroupForApproval service operation. The approval process includes several automated checks for relevance and adherence to Editorial Guidelines. Generally, an ad is approved or disapproved immediately after being submitted. In some cases, however, the process might take up to five business days.
The following PHP example shows how to submit an ad group for approval by using
SubmitAdGroupForApproval. This example assumes that you have already created your ads and keywords. This example also assumes that you have already determined which ad group ID will be submitted for approval; you must substitute your ad group ID for the
$adGroupId variable that is assigned
50786905 in the following code.
Lead Programming Writer
Microsoft adCenter API
// This program requires the following PHP extensions:
// To ensure that a cached WSDL is not being used,
// disable WSDL caching.
$adGroupId = 50786905; //Application-specific value.
// Use either the sandbox or production URI.
// This example is for the sandbox URI.
// The following commented-out line contains the production URI.
//$URI = "https://adcenterapi.microsoft.com/api/advertiser/v5/";
// The Microsoft adCenter API namespace.
$xmlns = "https://adcenter.microsoft.com/api/advertiser/v5";
// The proxy for the Campaign Management Web service.
$URI . "CampaignManagement/CampaignManagementService.svc?wsdl";
// The name of the service operation that will be called.
$action = "SubmitAdGroupForApproval";
// The user name, password, and developer token are
// expected to be passed in as command-line
// $argv is the PHP file name.
// $argv is the user name.
// $argv is the password.
// $argv is the developer token.
if ($argc !=4)
"php file.php username password devtoken\n");
$username = $argv;
$password = $argv;
$developerTokenValue = $argv;
// Assign the credentials to the classes
// that are used by the SOAP headers.
// Create the SOAP headers.
// Create the SOAP input header array.
$inputHeaders = array
// Create the SOAP client.
$opts = array('trace' => true);
$client = new SOAPClient($campaignProxy, $opts);
// Specify the parameters for the SOAP call.
$params = array
'AdGroupId' => $adGroupId
// Execute the SOAP call.
$result = $client->__soapCall
array( $action.'Request' => $params ),
print "$action succeeded with Tracking ID "
catch (Exception $e)
print "$action failed.\n";
// Display the fault code and the fault string.
print $e->faultcode . " " . $e->faultstring . ".\n";
print "TrackingID: " .
$e->detail->ApiFaultDetail->TrackingId . ".\n";
// Process operation errors.
// An array of operation errors has been returned.
// A single operation error has been returned.
$obj = $e->detail->ApiFaultDetail->OperationErrors;
foreach ($obj as $operationError)
print "Operation error " .
$operationError->Code . " encountered. ";
print $operationError->Message . "\n";
// Definitions for classes that are used by the SOAP headers.