Logging in the merchant and affiliate

Here is an example of one click login for merchant and affiliate using API. You can redirect automatically logged in affiliate to his/her panel.

Logging in as merchant:
include_once('PapApi.class.php');
$session = new Pap_Api_Session("http://demo.postaffiliatepro.com/scripts/server.php");
if(!@$session->login("merchant@example.com", "demo")) {
  die("Cannot login. Message: ".$session->getMessage());
}
If you want to redirect user (merchant/affiliate) to his panel after Pap_Api_Session is created you can do it using following code:
// redirecting to merchant panel (requires merchant session)
header('Location: '.$session->getUrlWithSessionInfo('http://demo.postaffiliatepro.com/merchants/index.php'));
Logging in as affiliate:
include_once('PapApi.class.php');
$session = new Pap_Api_Session("http://demo.postaffiliatepro.com/scripts/server.php");
if(!@$session->login("affiliate@example.com", "demo", Pap_Api_Session::AFFILIATE)) {
  die("Cannot login. Message: ".$session->getMessage());
}
Of course, as an affiliate you don't have access to the functionality of merchant, for example to the list of all affiliates.
// redirecting to affiliate panel (requires affiliate session)
header('Location:'.$session->getUrlWithSessionInfo('http://demo.postaffiliatepro.com/affiliates/panel.php'));
If you need to login in different than default language, then you can achieve this using another (optional) parameter when creating session. Language code for every single language can be found in your merchant panel > configuration > languages and regional settings > import language > column "Language". For example English languages has en-US code, Spanish language has es code etc. Then the login session would look like this: 
login("affiliate@example.com", "demo", Pap_Api_Session::AFFILIATE, language_code)
More about Pap_Api_Session
 
If the merchant does not know the password of the affiliate then the following example comes in handy: