API di AffiliationSoftware
AffiliationSoftware dispone di un API (application programming interface) che consente agli sviluppatori di connettere il programma di affiliazione con il proprio sito e svolgere determinate azioni in modo automatico. È possibile ad esempio approvare o rifiutare le commissioni degli affiliati in base allo stato dell’ordine, iscrivere un utente al programma di affiliazione quando si iscrive al proprio sito, e molto altro ancora!
Come usare l’API di AffiliationSoftware
L’API di AffiliationSoftware si può richiamare unicamente con richieste POST e utilizzando la funzione cURL di PHP. Il risultato di ogni chiamata ritorna un messaggio in formato JSON. Affinché l’API funzioni basta abilitare il plugin apposito che mostra nella pagina apposita la propria URL e la chiave necessaria per comunicare con il programma di affiliazione.
Pannello Admin > Impostazioni > API
Transazioni
Leggere una transazione
$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 ) );
Modificare lo stato di una transazione
$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 ) );
Aggiungere un transazione
$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 ) );
Cancellare una transazione
$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 ) );
Affiliati
Leggere un affiliato
$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 ) );
Iscrivere / aggiungi un affiliato
$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 ) );
Modificare lo stato di un affiliato
$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 ) );
Cancellare un affiliato
$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 ) );
Pagare un affiliato
$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 ) );
Siti web
Modificare lo stato di un sito web
$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 ) );
Banner e link
Leggere un banner / link
$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 ) );
Campagne
Leggere una campagna pubblicitaria
$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 ) );
Lista delle campagne pubblicitarie attive
$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 ) );
Statistiche
Leggere le statistiche e le transazioni
$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 ) );