Add DirectLink URL via API

Here is an example of how to add a DirectLink URL via API using merchant login credentials.
NOTE: You will need to know the exact userid of the affiliate to whom the DirectLink URL should be assigned.
You can get the userid of an affiliate via the following API:

while you can filter the affiliate via his/her username (e-mail address).
// the PapApi.class.php file can be downloaded from the merchant panel at:
// Tools > Integration > API Integration > Download PAP API
// This include assumes the PapApi.class.php file is in the same directory as this particular script. 
include 'PapApi.class.php';

$session = new Pap_Api_Session("https://URL_TO_PAP/scripts/server.php"); 
if(!$session->login("", "password")) {
  die("Cannot login. Message: ".$session->getMessage());

$request = new Gpf_Rpc_FormRequest("Pap_Merchants_User_DirectLinksForm", "add", $session);
//Leave it blank, it is populated automatically

//MANDATORY - userid of affiliate to whom the DirectLink URL will be assigned

//MANDATORY - DirectLink URL pattern

//MANDATORY - possible values: A,P,D

//Leave it blank = All campaigns
//alternatively define a particular Campaign ID



//OPTIONAL - note for the merchant

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

// Get the response
$response = $request->getStdResponse();
if ($response->success == 'Y') { 
echo 'Success: ' . $response->message; 
} else { 
echo 'Unsuccess: ' . $response->message; 
NOTE: In the above-mentioned example you must replace URL_TO_PAP  with the real URL leading to your installation of Post Affiliate Pro (or Network).
Also, you will have to replace merchant@username.compassword with your merchant panel login credentials.