AffiliationSoftware’s API

AffiliationSoftware’s API

AffiliationSoftware has an API (application programming interface) that allows developers to connect their affiliate program with their website and perform certain actions automatically. For example it is possibile to approve or decline the affiliates’ commissions based on the order status, register an user to the affiliate program when he/she register on your website, and much more!


How to use the AffiliationSoftware’s API

The AffiliationSoftware’s API can only be called with POST requests and by using the PHP cURL function. The response of each call returns a message in JSON format. To make it work you just have to enable the plugin, then a page will appear containing the URL and the KEY you need to communicate with your affiliate program via API.

Admin Panel > Settings > API

AffiliationSoftware's API


Transactions

Read a transaction

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
	'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
	'afs_action' => 'transaction_read',
	'afs_transaction' => 'XXX', // transactionID or orderID
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

Change the status of a transaction

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
	'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
	'afs_action' => 'transaction_edit',
	'afs_transaction' => 'XXX', // transactionID or orderID
	'afs_key' => 'status',
	'afs_value' => '1',
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

Add a transaction

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
 'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
 'afs_action' => 'transaction_add',
 'afs_affiliate' => 'XXX', // affiliateID, RefID or email
 'afs_campaign' => '1', // campaginID (optional)
 'afs_commission' => '119.95',
 'afs_earn' => '299.95', // optional
 'afs_orderval' => '299.95', // optional
 'afs_orderid' => 'XXX', // optional
 'afs_type' => 's', // optional
 'afs_tier' => '1', // optional
 'afs_status' => '1', // optional
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

Delete a transaction

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
	'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
	'afs_action' => 'transaction_delete',
	'afs_transaction' => 'XXX', // transactionID or orderID
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

Affiliates

Read an affiliate

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
	'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
	'afs_action' => 'affiliate_read',
	'afs_affiliate' => 'XXX', // affiliateID, RefID or email
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

Sign up / add an affiliate

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
	'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
	'afs_action' => 'affiliate_add',
	'afs_name' => 'Name Surname',
	'afs_email' => 'test@test.test',
	'afs_password' => 'test', // optional
	'afs_lang' => 'en', // optional
	'afs_refid' => '123', // optional
	'afs_parent' => '', // optional
	'afs_sendmail' => '1', // optional
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

Change the status of an affiliate

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
	'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
	'afs_action' => 'affiliate_edit',
	'afs_affiliate' => 'XXX', // affiliateID, RefID or email
	'afs_key' => 'status',
	'afs_value' => '1',
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

Delete an affiliate

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
	'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
	'afs_action' => 'affiliate_delete',
	'afs_affiliate' => 'XXX', // affiliateID, RefID or email
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

Pay an affiliate

$afs_url = 'AFFILIATIONSOFTWARE_URL'; 
$afs_data = array( 
	'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY', 
	'afs_action' => 'affiliate_pay',
	'afs_affiliate' => 'XXX', // affiliateID, RefID or email
); 
$afs_api = curl_init( $afs_url ); 
curl_setopt( $afs_api, CURLOPT_POST, 1 ); 
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 ); 
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data ); 
$afs_res = curl_exec( $afs_api ); 
curl_close( $afs_api ); 
print_r( json_decode( $afs_res, true ) );

Websites

Change the status of a website

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
	'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
	'afs_action' => 'website_edit',
	'afs_website' => 'XXX', // websiteID or URL
	'afs_key' => 'status',
	'afs_value' => '1',
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

Banners & links

Read a banner / link code

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
	'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
	'afs_action' => 'banner_read',
	'afs_affiliate' => 'XXX', // affiliateID, RefID or email
	'afs_banner' => 'XXX', // bannerID
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

Campaigns

Read a campaign’s details

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
	'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
	'afs_action' => 'campaign_read',
	'afs_campaign' => 'XXX', // campaignID
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

List of active campaigns

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
	'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
	'afs_action' => 'campaign_read',
	'afs_country' => 'XXX', // Country code
        'afs_limit' => '3', // how many (optional)
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

Statistics

Read statistics and transactions

$afs_url = 'AFFILIATIONSOFTWARE_URL';
$afs_data = array(
 'afs_apikey' => 'AFFILIATIONSOFTWARE_API_KEY',
 'afs_action' => 'statistics_read',
 'afs_from' => 'YYYY-MM-DD', // from date
 'afs_to' => 'YYYY-MM-DD', // to date
 'afs_affiliate' => 'XXX', // affiliateID, RefID or email (optional)
 'afs_campaign' => 'XXX', // campaignID (optional)
);
$afs_api = curl_init( $afs_url );
curl_setopt( $afs_api, CURLOPT_POST, 1 );
curl_setopt( $afs_api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $afs_api, CURLOPT_POSTFIELDS, $afs_data );
$afs_res = curl_exec( $afs_api );
curl_close( $afs_api );
print_r( json_decode( $afs_res, true ) );

You may also be interested in: