The following API example shows how to obtain the unique IDs (or other details) of recurring rules that you see in the merchant panel at Transactions > Recurring commissions.
Note: The first parameter of setLimit() is an offset that is no longer used since version 5.11.8.1 — always pass 0. Paging is handled automatically: sending the same request object again returns the next page of records. The maximum number of records returned in one request is 500. Use the largest page size your script can handle, as it means fewer API calls. Details are described in the Gpf_Rpc_GridRequest article.
<?php include_once ("PapApi.class.php"); //this include assumes the PapApi.class.php is in the same dir as this script //change localhost/pap to the path of your Post Affiliate Pro installation $session = new Pap_Api_Session("https://URL_TO_PAP/scripts/server.php"); //login as merchant if(!$session->login("merchant@username.com", "MerchantPassword")) { // change it here for your username and password die("Cannot login. Message: ".$session->getMessage()); } $request = new Gpf_Rpc_GridRequest("Pap_Features_RecurringCommissions_RecurringCommissionsGrid", "getRows", $session); //enable all columns //id,userid,username,firstname,lastname,totalcost,orderid,datecreated,datelastcommission,rstatus,recurrencepresetname $request->addParam('columns', new Gpf_Rpc_Array(array(array('id'), array('userid'), array('username'), array('firstname'), array('lastname'), array('totalcost'), array('orderid'), array('datecreated'), array('datelastcommission'), array('rstatus'), array('recurrencepresetname')))); // sets the page size to 500 rows, which is the maximum per request // the first parameter is an offset which is not used, always keep it at 0 $request->setLimit(0, 500); //Add some filter //filtering only the approved ones $request->addFilter('rstatus',Gpf_Data_Filter::EQUALS,'A'); // execute request in a loop to load all data // sending the same request again returns the next page do { // send request try { $request->sendNow(); } catch(Exception $e) { die("API call error: ".$e->getMessage()); } // request was successful, get the grid result and its recordset $recordset = $request->getGrid()->getRecordset(); // iterate through the records foreach($recordset as $rec) { echo 'ID of recurring prescription: '.$rec->get('id').', OrderID:'.$rec->get('orderid').'<br>'; } } while ($recordset->getSize() == $request->getLimit()); ?>