Approve affiliate with API

Following example shows, how you can approve pending affiliate using Post Affiliate Pro API.
Include API:
Login as merchant to get rights manipulating with Affiliate rows:
$session = new Pap_Api_Session("");
if(!$session->login("", "demo")) {
  die("Cannot login. Message: ".$session->getMessage());
Load affiliate data:
// loading affiliate by his ID
$affiliate = new Pap_Api_Affiliate($session);
// You can load affiliate by system user ID, referral ID or username, so one of the following commands
try {
  if(!$affiliate->load()) {
    die('Cannot load affiliate, error: '.$affiliate->getMessage());
} catch (Exception $e) {
  die('Cannot load affiliate, error: '.$e->getMessage());
Change status of affiliate to approved and save it:
$affiliate->setStatus('A');  //A - Approved, D - Declined, P - Pending
try {
  if ($affiliate->save()) {
    echo "Affiliate saved successfully";
  } else {
    die("Cannot save affiliate: ".$affiliate->getMessage());
} catch (Exception $e) {
  die("Error while communicating with PAP: ".$e->getMessage());