The following sample code shows how to display the list of affiliates invited to a particular private campaign.
<?php
//the PapApi.class.php can be downloaded from the merchant panel:
//Tools > Integration > API Integratoin > Download PAP API
include_once 'PapApi.class.php';
//campaign ID of the particular private campaign
$campaignID = '9e394454';
$session = new Pap_Api_Session("https://URL_TO_PAP/scripts/server.php");
if(!@$session->login("merchant@login.com","merchantPassword")) {
die("Cannot login. Message: ". $session->getMessage());
}
$request = new Gpf_Rpc_GridRequest("Pap_Features_Common_AffiliateGroupGrid", "getRows", $session);
// sets limit to 30 rows, offset to 0 (first row starts)
$request->setLimit(0, 30);
//you can use general search
$request->addParam('campaignid',$campaignID);
// send request
try {
$request->sendNow();
} catch(Exception $e) {
die("API call error: ".$e->getMessage());
}
// request was successful, get the grid result
$grid = $request->getGrid();
// get recordset from the grid
$recordset = $grid->getRecordset();
//to see what fields are avaiable, uncomment the line below
//print_r($recordset);
iterate($recordset,$session);
$totalRecords = $grid->getTotalCount();
$maxRecords = $recordset->getSize();
if ($maxRecords != 0) {
$cycles = ceil($totalRecords / $maxRecords);
for($i=1; $i<$cycles; $i++) {
// now get next 30 records
$request->setLimit($i * $maxRecords, $maxRecords);
$request->sendNow();
$recordset = $request->getGrid()->getRecordset();
iterate($recordset,$session);
}
}
function iterate($recordset,$session) {
// iterate through the records
foreach($recordset as $rec) {
$status='';
$status=$rec->get('rstatus');
switch ($status){
case 'A':
$status = "Approved";
break;
case 'P':
$status = "Pending";
break;
case 'A':
$status = "Declined";
break;
default:
$status='';
}
echo $rec->get('firstname'). ' '.$rec->get('lastname').' - '.$rec->get('username').' , Status: '.$status.', Date Added: '.$rec->get('dateadded').'<br>';
}
}
?>