API Example Advertiser Edit Campaign

From InClickAdServer

Editing an Existing Campaign

This API Service Request will replace data for an existing campaign with the data provided in this Service Request.

The Code Example

Breaking Down the Code

This require references the local inClick Ad Server deployment configuration files allowing your code to utilize the pre-packaged API Objects as well as the bundled PHPOlait services.


These requires (includes) contain the API Objects and Classes needed for this API Service Request.


The $base_url is the URL to your inClick Ad Server deployment, the ad server root URL. For local host API usage, the constant of INCLICK_WEB_URL is defined in the globals.php file referenced earlier. Remote deployments, deployments where the ad server and API Request Location are not on the same server, would change this to the fully qualified URL to the ad server root directory.

The $service_key is one of the the api_service_keys values you created for your ad server. (more information)


The $user_id is the inClick Advertiser account number we will be working with for this API Service Request. For this example, we are working with the House Advertiser account, 1001.


Here we populate the campaign objects with the existing data for the campaign.


Each $campaign->SetXXXXX corresponds to the associated data for that campaign.

If any of the $campaign-> objects are not populated for an update, the previous information for that object will be used.


The $campaign->AddXXXX objects allow you to added multiple values as needed. In this example, the campaign we are creating will be targeted to viewers in two countries, United States of America (US) and Canada (CA). We then set each country as seen in this code snippet. Country codes are based on ISO-3166 standards.

If any of the $campaign->addXXXX objects are not populated for an update, the previous information for that object will be used.


The $campaign->setDailyBudget and $campaign->setMaximumCPC objects are just as they are described, the daily budget and the max cost-per-click values for this campaign.


The $campaign->setEndDate and $campaign->setStartDate objects are just as they are described, the starting and ending date for the campaign. If these values are not set, the ad server will assume the start date of today and and end date ten years from today.

'WARNING:' Values for $campaign->setEndDate and $campaign->setStartDate are integer timestamps. Do not enter date formatted values! For example, the timestamp value for May 24, 2023 is 1684900800.

The #campaign->setTypeCode defines the campaign type. Only cost-per-click is supported at this time.


This line is the API Service Reqeust that sends the campaign data to your inClick Ad Server deployment. If a failure occurs, the error code and corresponding error message are returned as objects:

$result->getErrorCode()
$result->getErrorMessage()

If this request is successful, the Campaign ID assigned is available in the following object:

$result->getReturnValue()

This section of code is provided to give you a visual confirmation of what occurred.