How to Submit an Ad Group for Approval in PHP (V5)

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.

Walter Poupore
Lead Programming Writer
Microsoft adCenter API


// This program requires the following PHP extensions:
//    php_soap.dll
//    php_openssl.dll

// To ensure that a cached WSDL is not being used,
// disable WSDL caching.
ini_set("soap.wsdl_cache_enabled", "0");


    $adGroupId = 50786905;  //Application-specific value.

    // Use either the sandbox or production URI.
    // This example is for the sandbox URI.
    $URI =
    // The following commented-out line contains the production URI.
    //$URI = "";

    // The Microsoft adCenter API namespace.
    $xmlns = "";

    // The proxy for the Campaign Management Web service.
    $campaignProxy =
        $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
    // arguments.
    // $argv[0] is the PHP file name.
    // $argv[1] is the user name.
    // $argv[2] is the password.
    // $argv[3] is the developer token.
    if ($argc !=4)
          "php file.php username password devtoken\n");
    $username = $argv[1];
    $password = $argv[2];
    $developerTokenValue = $argv[3];

    // Assign the credentials to the classes
    // that are used by the SOAP headers.
    $userCredentials=new UserCredentials();
    $developerToken=new DeveloperToken();
    $applicationToken=new ApplicationToken();

    // Create the SOAP headers.
    $headerApplicationToken =
        new SoapHeader
    $headerDeveloperToken =
        new SoapHeader
    $headerUserCredentials =
        new SoapHeader

    // 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 "
          . $outputHeaders['ApiCallTrackingData']->TrackingId
          . ".\n";


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.
    if (isset(
        if (is_array(
            // An array of operation errors has been returned.
            $obj =
            // 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.
class ApplicationToken
    public $Value;
class DeveloperToken
    public $Value;
class UserCredentials
    public $Password;
    public $Username;


Comments (3)
  1. Cnorred says:

    Thanks for posting this code.Me also one of the PHP programmer.This will more helpful to me.

  2. Cnorred says:

    Great Code! There is a great need for more in-depth reviews of certain products and technologies. Your tips are really helpful for anybody who wants to create reviews of any type. Great job

  3. ajay rathore says:

    Sabase sasta HP, DELL, SONY, ASUS,laptops & computers.We are

                   dealing in all types computers, laptops,data card ,dth,mobiles,

                   computer peripherals, laptop peripherals,printer,LCD & LED

                   sales and services For more information contact us on-

                   +91-9214645678 or mail us on & log

                   On sush04ngp1041

Comments are closed.

Skip to main content