Get the list of PAN Accounts via API

The following sample code shows how a network-owner can get the list of accounts of his/her Post Affiliate Network via API
 
<?php
//your PapApi.class.php file can be downloaded in the merchant panel: Tools>Integration>API Integration>Download PAP API
include ("PapApi.class.php"); //this include assumes the PapApi.class.php is in the same dir as this script
  
$session = new Pap_Api_Session("https://URL_TO_PAN/scripts/server.php"); 
//login as merchant
if(!$session->login("network-owner@example.com", "demo")) { // change it here for your username and password 
  die("Cannot login. Message: ".$session->getMessage());
}

$request = new Gpf_Rpc_GridRequest("Pap_Features_AffiliateNetwork_AccountsGrid", "getRows", $session);

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

// request was successful, get the count of returned rows
echo 'Number of results: '.$request->getStdResponse()->count . '<br>';

// request was successful, get the grid result
$grid = $request->getGrid();
// get recordset from the grid
$recordset = $grid->getRecordset();

//print_r($recordset); //can be useful to see all the data fields available

// iterate through the records
foreach($recordset as $rec) {
  echo 'AccountId: ' . $rec->get('accountid'). ' || Name: ' . $rec->get('name').' || Email: ' . $rec->get('name').' || Status: ' . $rec->get('rstatus').'<br>';
}

?>
 
×