Affiliate Software Documentation
API Sample Code for Automatic Account Registration
The attached file is an example PHP file that illustrates how to utilize the Affiliate Automation API for auto account registration. It is also available in the /docs/ folder of the affiliate program download.
In order to test it, please follow these steps:
- Log-in to your Affiliate Admin Area.
- Click on Settings > Global Configuration, and go to the Automation Tab.
- On the Auto Signup Sub tab, enable automation and enter a 20 digit Automation Access Key and Automation Secret ID
- Click Save Changes to save it.
- Unzip the downloaded autologin.php file. Open it up for editing.
- On the top area, enter the $url, $access key, and $access_id. The $url is the full path to your affiliate program installation. The $access_key and $access_id are the Automation Access Key and Automation Secret ID that you set up earlier.
- Save the file and upload it to your site.
- Go to the URL where you uploaded the file. For example: http://www.yourdomain.com/autologin.php.
- To try out each automation task, append a $_GET value of "type" for each action. Her are some examples:
- http://www.yourdomain.com/autologin.php?type=register - This will automatically create an account called 'automation', with email address 'automation@jrox.com'
Each example function uses name-value pairs and PHP Curl to connect to the automation API.
Sample Code for auto registration:
$url = 'http://www.yourdomain.com/affiliates'; //NO TRAILING SLASH
$access_key = 'xxxxxxxxxxxxxxxxxxxxxxx';
$access_id = 'xxxxxxxxxxxxxxxxxxxxx';
$sdata = array(
'access_key' => $access_key,
'access_id' => $access_id,
'email' => 'automation@jrox.com',
'fname' => 'automation',
//'affiliate_group' => '2',
//'password' => 'dc724af18fbdd4e59189f5fe768a5f8311527050',
//'encrypted' => true,
'sponsor' => !empty($_COOKIE[$aff_cookie]) ? $_COOKIE[$aff_cookie] : '',
);
$fields = "";
foreach( $sdata as $key => $value ) $fields .= "$key=" . urlencode( $value ) . "&";
$ch = curl_init($url . '/automate/login');
curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, '50');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); // use HTTP POST to send form data
$resp = curl_exec($ch); //execute post and get results
curl_close ($ch);
$result = json_decode( $resp);
echo $result->msg;
There are a few options as commented in the code above:
- affiliate_group - you can specify which affiliate group the affiliate user will be a part of. Default is '1'
- password - if you want to send the password hash to the affiliate software, you can add this line
- encrypted - if the password hash is already encrypted using md5 encryption
- sponsor - the sponsor cookie, if any, so that the affiliate can be placed below the referring sponsor
There is more sample code in the /docs subfolder of the zip file for Affiliate Manager, if you want to play with other API functions like auto-login, cookie setting, etc.