API Example Create a Publisher Account

From InClickAdServer

Creating a Publisher Account

This API Service Request will create a new Publisher account.

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)


This is where we create an instance of the classes needed to create a new publisher.


Each $publisher_user->setXXXX corresponds to the data being stored. For example, $publisher_user->setFirstName is the first name of the account holder.


This line sets the starting commission rate for the publisher. The $publisher_user->setCommissionRate() object expects the value to be in its raw from. For example, a commission rate of 35% is entered as "0.35". In this example, we obtained the default commission rate from the inClick Ad Server deployments configuration file (the globals.php require). Since the configuration file uses a whole number, we divide it by 100 to get the decimal equivalent.


These lines send the data to the ad server, processing the new publisher account request. If a failure occurs, the error code and corresponding error message are returned as objects:

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

On a successful retrieval, the object values can be found within the following object:

$result->getReturnValue()

This section of code is provided to give you a visual confirmation of what occurred, or to let you know what error occurred.