Request structure

Your URL address for webservice constructs as below

https://[ clients system address ]/affiliate/

Every request has system parameters as below. All the parameters are lowercase and case-sensitive. Http client has to use the POST protocol.

Request parameters

affuid Username
affpPassword
affrequestOneSystem command to be executed
afflan (optional)Language information. The Clients default language unless provided.
affsessionid (optional)SessionID for the connection

You may send username and password with all requests or you may use “userdata” request to get current user information and SessionID. After you retrieve SessionID you may send it with each request with affsessionid parameter without username and password for better performance and security.

Sample PHP Curl Request ClassTo make more brief and understandable documentation we wrote a sample PHP curl class script which we will use in further command descriptions.
Please download and examine it before you continue from the link below.

 

PHP Code example:

<?php

$url = “http://HOST_COMPANY.onesystem.online/affiliate/”;

// Build POST parameters
$postFields = [
“affuid” => YOUR_USERNAME,
“affp” => YOUR_PASSWORD,
“affrequest” => “userdata”
];

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);

// Optional but recommended if HTTPS
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($response === false) {
$error = curl_error($ch);
curl_close($ch);
throw new Exception(“cURL Error: “ . $error);
}

curl_close($ch);

// Check HTTP status
if ($httpCode !== 200) {
throw new Exception(“HTTP Error: “ . $httpCode . ” – “ . $response);
}

// Decode JSON
$JSONData = json_decode($response);

if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception(“Returned data is not valid JSON: “ . json_last_error_msg());
}

// Use data
if (isset($JSONData->sessionid)) {
$sessionid = $JSONData->sessionid;

// USE $sessionid in further requests for better performance
}

// Handle possible array resultsets
// Example:
if (is_array($JSONData)) {
foreach ($JSONData as $row) {
// process each object
}
}

echo “Request successful.\n;