With use of Gpf_Rpc_GridRequest you can use this code to get all banners from your merchant panel:
include 'path/to/your/api/file/PapApi.class.php';
$session = new Pap_Api_Session("https://localhost/scripts/server.php"); //replace https://localhost/scripts with link to your PAP installation URL
if(!$session->login("merchant_name", "merchant_password")) {
die('Failed authentication');
}
$request = new Gpf_Rpc_GridRequest("Pap_Merchants_Banner_BannersGrid", "getRows", $session);
$request->setLimit(0, 30); //get me only first 30 banners
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();
// iterate through the records
foreach($recordset as $rec) {
echo 'Banner name: '.$rec->get('name').'<br>';
}
// In case there were more than 30 records, let's get the rest of them in cycles,
// this paging is working since version 5.11.8.1
while ($recordset->getSize() == $request->getLimit()) {
$request->sendNow();
$recordset = $request->getGrid()->getRecordset();
foreach($recordset as $rec) {
echo 'Banner name: '.$rec->get('name').'<br>';
}
}
include 'path/to/your/api/file/PapApi.class.php';
$session = new Pap_Api_Session("https://localhost/scripts/server.php"); //replace https://localhost/scripts with link to your PAP installation URL
if(!$session->login("merchant_name", "merchant_password")) {
die('Failed authentication');
}
$request = new Gpf_Rpc_GridRequest("Pap_Merchants_Banner_BannersGrid", "getRows", $session);
$request->setLimit(0, 30); //get me only first 30 banners
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();
// iterate through the records
foreach($recordset as $rec) {
echo 'Banner name: '.$rec->get('name').'<br>';
}
// In case there were more than 30 records, let's get the rest of them in cycles
$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 through the records
foreach($recordset as $rec) {
echo 'Banner name: '.$rec->get('name').'<br>';
}
}
}
Optionally you can get additional fields from $rec like:
- bannerid
- accountid
- campaignid
- campaignname
- rtype
- rstatus
- name
- destinationurl
- dateinserted
- size
- data1-data9
- rorder
- ctype
- wrapperid
- description
- seostring