This example shows how to create new affiliate, more about class Pap_Api_Affiliate you can read here or about class Pap_Api_AffiliateSignup you can read here.
 
<?php
include 'PapApi.class.php'; //Download PapApi.class.php from the merchant panel
$session = new Pap_Api_Session("URL_to_PAP/scripts/server.php");
if(!@$session->login("merchant@example.com","merchant_password")) {
  die("Cannot login. Message: ". $session->getMessage());
}

$affiliate = new Pap_Api_Affiliate($session);

$affiliate->setUsername("some@email.com");
$affiliate->setFirstname("John");
$affiliate->setLastname("Smith");
$affiliate->setData(3, "Affiliate City");
//$affiliate->setPassword("aff_password");

try {
  if ($affiliate->add()) {
    echo "Affiliate saved successfuly";
  } else {
    die("Cannot save affiliate: ".$affiliate->getMessage());
  }
} catch (Exception $e) {
    die("Error while communicating with PAP: ".$e->getMessage());
}

?>
 
Use Pap_Api_AffiliateSignup for using same way as affiliate signup form, you don't need to use merchant credentials:
 
<?php
include 'PapApi.class.php'; //Download PapApi.class.php from the merchant panel
$session = new Pap_Api_Session("URL_to_PAP/scripts/server.php");

$affiliate = new Pap_Api_AffiliateSignup($session);

$affiliate->setUsername("testaffiliate@email.com");
$affiliate->setParentUserId('testaff');
$affiliate->setFirstname("test");
$affiliate->setLastname("affiliate");
$affiliate->setRefid('testaff10');
$affiliate->setData(1, "urlExample");
$affiliate->setData(2, "companyNameExample");
$affiliate->setData(3, "streetExample");
$affiliate->setData(4, "cityExample");
$affiliate->setData(5, "streetExample");
$affiliate->setData(6, "GB");

$affiliate->setPassword("affpassword"); // use it if you want to set password

try {
  if ($affiliate->add()) {
    echo "Affiliate saved successfuly id: " . $affiliate->getUserid();
  } else {
    die("Cannot save affiliate: ".$affiliate->getMessage());
  }
} catch (Exception $e) {
    die("Error while communicating with PAP: ".$e->getMessage());
}
?>
 
For some additional configuration like to "Do not sent notification email" use Low level API, example:
 
<?php
include 'PapApi.class.php'; //Download PapApi.class.php from the merchant panel
$session = new Pap_Api_Session("URL_to_PAP/scripts/server.php");
if(!@$session->login("merchant@example.com","merchant_password")) {
  die("Cannot login. Message: ". $session->getMessage());
}

$request = new Gpf_Rpc_FormRequest('Pap_Merchants_User_AffiliateForm', 'add', $session);

$request->setField('username', 'some@email.com');
$request->setField('firstname', 'John');
$request->setField('lastname', 'Smith');
$request->setField('refid', 'MyRefId');
$request->setField('dontSendEmail', 'Y');

try {
  $request->sendNow();
}
catch(Exception $e) {
  die("API call error: ".$e->getMessage());
}

$response = $request->getStdResponse();
if ($response->success == 'Y') {
  echo 'Successful: ' . $response->message;
}
else {
  echo 'Unsuccessful: ' . $response->message;
}
?>
 
Possible params are there fields from signup form (Configuration -> Affiliate signup -> Fields tab). Mandatory fields are also mandatory in this request except field password. Other possible params:
 
rpassword
photo - url or path to photo image
rstatus - A (approved), P (pending), D (declined)
note
dontSendEmail - Y or N
createSignupReferralComm - Y or N