Microsoft Advertising APIs
Submit an Ad Group for Approval in Perl

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 Perl 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. For examples of how to create ads and keywords, see Create Ads in Perl and Create Keywords in Perl, respectively.

package adCenterAPI;

# For release code, use the following SOAP::Lite statement.
#use SOAP::Lite ( +maptype => {} );
# For debugging code, use the following SOAP::Lite statement.
use SOAP::Lite ( +trace => all, maptype => {} );

use strict;

eval
{
# Use either the sandbox or the production URI.
# This example is for the sandbox URI.
my $URI = "https://sandboxapi.adcenter.microsoft.com/Api/Advertiser/V6";
# The following commented-out line contains the production URI.
#my $URI = "https://adcenterapi.microsoft.com/Api/Advertiser/V6";

# The Microsoft adCenter API namespace.
my $xmlns = "https://adcenter.microsoft.com/api/advertiser/v6";

# The proxy for the Campaign Management Web service.
my $campaignPROXY =
    $URI."/CampaignManagement/CampaignManagementService.svc?wsdl";

# The service operation that will be called.
my $action = 'SubmitAdGroupForApproval';

# The Web service.
my $campaignManagementService = SOAP::Lite->new(
    uri => $URI, 
    proxy => $campaignPROXY, 
    on_action => ( sub { return $action } ));
$campaignManagementService->autotype(0);
$campaignManagementService->multirefinplace(1);
$campaignManagementService->readable(1);

my $username = "username";
my $password = "password";
my $devToken = "devtoken";
my $appToken = "apptoken";
my $customerAccountId = 1234;
my $customerId = 5678;
my $adGroupId = 123456; # Application-specific value.

# Assemble the service operation header.
my @header = CreateV6Header(
    $username,
    $password,
    $devToken,
    $appToken,
    $customerAccountId,
    $customerId);

my $method = SOAP::Data->name
(
    $action.'Request'
)-> attr({xmlns => $xmlns});

my @params = 
(
    @header,
    SOAP::Data->name("AdGroupId" => $adGroupId)
);  

my $response = 
    $campaignManagementService->call
    (
        $method => @params
    );

# Check for errors.
if ($response->fault) 
{
    print "$action failed.\n";
    
    # Display the adCenter tracking ID.
    my $trackingId = $response->valueof
    (
        '//AdApiFaultDetail/TrackingId'
    );
    print "TrackingId: $trackingId\n";

    # Display any operation errors.
    my @operationErrors = $response->valueof
    (
        '//AdApiFaultDetail/Errors/AdApiError'
    );
    
    foreach my $operationError (@operationErrors)
    {
        print "Operation error ($operationError->{Code}) encountered. ";
        print "$operationError->{Message}\n";
    }
}
else 
{
   print "$action succeeded.\n";

    # Display the adCenter tracking ID.
    my $trackingId = $response->valueof
    (
        '//TrackingId'
    );
    print "TrackingId: $trackingId\n";
    print "\n";
}

sub CreateV6Header
{
    # Method parameters.
    my (
        $username,
        $password,
        $devtoken,
        $apptoken,
        $customeraccountid,
        $customerid) = @_;
    
    # Initialize the application token.
    my $AppToken = SOAP::Header->name
    (
        "ApplicationToken"=>$apptoken
    )->attr({xmlns => $xmlns});
    
    # Initialize the developer token.
    my $DevToken =SOAP::Header->name
    (
        "DeveloperToken"=>$devtoken
    )->attr({xmlns => $xmlns});
    
    # Initialize the user name.
    my $UserName =SOAP::Header->name
    (
        "UserName"=>$username
    )->attr({xmlns => $xmlns});
    
    # Initialize the password.
    my $Password =SOAP::Header->name
    (
        "Password"=>$password
    )->attr({xmlns => $xmlns});
    
    # Initialize the customer account ID.
    my $CustomerAccountId =SOAP::Header->name
    (
        "CustomerAccountId"=>$customeraccountid
    )->attr({xmlns => $xmlns});
    
    # Initialize the customer ID.
    my $CustomerId =SOAP::Header->name
    (
        "CustomerId"=>$customerid
    )->attr({xmlns => $xmlns});
    
    # Assemble the header parameters.
    my @headerParams =
    (
        $AppToken,
        $CustomerAccountId,
        $CustomerId,
        $DevToken,
        $Password,
        $UserName, 
    );
    
    return @headerParams;
}
};
warn $@ if $@;
See Also

Concepts

Create Ads in Perl
Create Keywords in Perl
Hello Microsoft adCenter Sample in Perl

Page view tracker