Affiliate Software Documentation

API Sample Code for Automatic Account Login

Please note that these instructions are for those with PHP development and programming experience. If you need help creating custom automation code with your shopping cart or site, please contact us.

The attached file is an example PHP file that illustrates how to utilize the Affiliate Automation API. It is also available in the /docs/ folder of the affiliate program download.

In order to test it, please follow these steps:

  1. Login to your Affiliate Admin Area.
  2. Click on Settings > Global Configuration, and go to the Automation Tab.
  3. On the Auto Signup Sub tab, enable automation and enter a 20 digit Automation Access Key and Automation Secret ID
  4. Click Save Changes to save it.
  5. Unzip the downloaded autologin.php file. Open it up for editing.
  6. 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.
  7. Save the file and upload it to your site.
  8. Go to the URL where you uploaded the file. For example: http://www.yourdomain.com/autologin.php.
  9. To try out each automation task, append a $_GET value of "type" for each action. Here 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'
    • http://www.yourdomain.com/autologin.php?type=login - To auto login the 'automation@jrox.com' account

Each example function uses name-value pairs and PHP Curl to connect to the automation API.

Sample Code for auto login:

$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,
'ip' => $_SERVER['REMOTE_ADDR'],
'user_agent' => $_SERVER['HTTP_USER_AGENT'],
'email' => 'automation@jrox.com',
'bypass_pwd' => 1,
'encrypted' => false,
);

$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);

$jam_cookie = json_decode($resp);

if (setcookie(
$jam_cookie['name'],
$jam_cookie['value'],
$jam_cookie['length'],
$jam_cookie['path'],
$jam_cookie['domain'],
0
))
{
echo 'SUCCESS: User logged in'; 
}

Once you've seen how the API works, you can use some of the sample code from the autologin.php file and insert it into the account creation / registration, account log-in modules for each of your web stores, or payment gateway scripts.