How to automatically log in as an affiliate

You can do it using our API:

Generate redirect link to affiliate panel if you know affiliate username (available since version 5.10.4.1):

<?php
/* *************** CONFIGURATION PART ****************** */
$papURL = 'https://URL_TO_PostAaffiliatePro/'; //URL of Post Affiliate Pro installation
$mUsername = 'merchant@username.com'; //replace it with your merchant username
$mPassword = '123456'; //replace it with your merchant password


//username of the affiliate you want to log in with
$usernameOfAffiliate = 'affiliate@example.com';
/* *************** /CONFIGURATION PART ***************** */

//The API file PapApi.class.php can be downloaded in the merchant panel: Tools> Integration> API Integration
include_once('PapApi.class.php'); //This include assumes the API file is in the same directory as this script

$session = new Pap_Api_Session($papURL.'scripts/server.php');
if (!@$session->login($mUsername, $mPassword)) {
    die('Cannot login. Message: '.$session->getMessage());
}

$affiliate = new Pap_Api_Affiliate($session);
$affiliate->setUsername($usernameOfAffiliate);

try {
  $loginKey = $affiliate->getLoginKey();
} catch (Exception $e) {
  die("API request error: ".$e->getMessage());
}

//redirecting to the affiliate login page and logging in
header('Location: '.$papURL.'affiliates/login.php?LoginKey='.$loginKey);      
?>

 Generate redirect link to affiliate panel if you know affiliate user ID (available since version 5.10.4.1):

<?php
/* *************** CONFIGURATION PART ****************** */
$papURL = 'https://URL_TO_PostAaffiliatePro/'; //URL of Post Affiliate Pro installation
$mUsername = 'merchant@username.com'; //replace it with your merchant username
$mPassword = '123456'; //replace it with your merchant password


//username of the affiliate you want to log in with
$userId = '11111111';
/* *************** /CONFIGURATION PART ***************** */

//The API file PapApi.class.php can be downloaded in the merchant panel: Tools> Integration> API Integration
include_once('PapApi.class.php'); //This include assumes the API file is in the same directory as this script

$session = new Pap_Api_Session($papURL.'scripts/server.php');
if (!@$session->login($mUsername, $mPassword)) {
    die('Cannot login. Message: '.$session->getMessage());
}

$affiliate = new Pap_Api_Affiliate($session);
$affiliate->setUserid($userId);

try {
  $loginKey = $affiliate->getLoginKey();
} catch (Exception $e) {
  die("API request error: ".$e->getMessage());
}

//redirecting to the affiliate login page and logging in
header('Location: '.$papURL.'affiliates/login.php?LoginKey='.$loginKey);      
?>

 

NOTE: You have to replace the URL_TO_PostAffiliatePro with the real URL of your Post Affiliate Pro installation
×