API

API

AffiliationSoftware has an API (Application Programming Interface) that allows developers to directly connect with the affiliate network and do certain actions automatically. For example, you can automatically approve or decline affiliate transactions based on the order status, or automatically signup an affiliate when he register to your site, and much more.


HOW DOES IT WORK

The AffiliationSoftware API can be called up using the PHP cURL function, sending data via POST. The result of each call returns a JSON message. If you want to use the API you can contact us to request your API key. Listed below are the actions available and the related codes to use for making API calls.


CHANGE TRANSACTION STATUS

$data = array(
  'action' => 'transaction_status',
  'transaction' => 'xxx', // enter the transaction ID or orderID
  'status' => '1', // enter the status (1 = approved, 2 = declined)
);
$api = curl_init( 'http://xxx.affiliationsoftware.app/script/api?key=xxx' ); // enter your API URL and key
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );


Edit the affiliate profile

$data = array(
  'action' => 'affiliate_edit',
  'affiliate' => 'xxx', // enter the affiliate ID or email
  'field' => 'status', // columns: name, email, password, status, note
  'value' => '1', // enter the corresponding value
);
$api = curl_init( 'http://xxx.affiliationsoftware.app/script/api?key=xxx' ); // enter your API URL and key
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );


Signup an affiliate

$data = array(
  'action' => 'affiliate_add',
  'name' => 'test affiliate', // required
  'email' => 'test@test.test', // required
  'password' => 'test123', // required
  'language' => 'it', // optional
  'parent' => '', // optional
);
$api = curl_init( 'http://xxx.affiliationsoftware.app/script/api?key=xxx' ); // enter your API URL and key
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );


Read affiliate data

$data = array(
  'action' => 'affiliate_data',
  'affiliate' => 'xxx', // enter the affiliate ID or email
);
$api = curl_init( 'http://xxx.affiliationsoftware.app/script/api?key=xxx' ); // enter your API URL and key
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );


Read statistics and commissions

$data = array(
  'action' => 'affiliate_stats',
  'from' => 'YYYY-MM-DD', // enter the start date
  'to' => 'YYYY-MM-DD', // enter the end date
  'affiliate' => 'xxx', // enter the affiliate ID or email (optional)
  'campaign' => 'xxx', // enter the campaign ID (optional)
);
$api = curl_init( 'http://xxx.affiliationsoftware.app/script/api?key=xxx' ); // enter your API URL and key
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );