Overview

Low level API is a set of classes formaking requests and processing responses. They can be used to make requests forthe entities that are not yet supported by high level API. Low level API classes have names informat Gpf_*****, in contrary with high level classes, whose namesare in format Pap_Api_*****.

Pap_Api_Session

class representing session (logged user). You must log in using this object before making any other requests. Methods: _constructor Pap_Api_Session($url)_ – creates session object. You have to specify full valid URL to the /scripts/server.php file of your installation. For example: _http://www.yoursite.com/affiliate/scripts/server.php_ _login($username, $password, $roleType, $languageCode)_ – authorizes the user and creates session object. The username and password must be your merchant or a...

Gpf_Rpc_Request

Gpf_Rpc_Request calls method of specified class. With this class you can call almost any class in the Post Affiliate Pro and do almost any action. For grids and forms, use Gpf_Rpc_GridRequest and Gpf_Rpc_FormRequest. Constructor: Gpf_RpcRequest($className, $methodName, $session) $className - name of the class you are calling. $methodName - name of the method in the class. Use addParam() if you want to pass parameters to the method. All available methods can be found out via debugging any r...

Gpf_Rpc_FormRequest

_Gpf_Rpc_FormRequest_ is used to send form information to the PAP. _Gpf_Api_Session_ uses this request to send log in information, for example. You can however use it to send other form information, like adding a banner or creating a campaign. Since this is a low level API call, it's not easy do those things as you need to either retrieve correct information (like commission group id) or you simply need to know those values (like campaign id for which you want to retrieve the commission group id...

Gpf_Rpc_GridRequest

This object is used to retrieve a grid (list of records, recordset). The grids can be used to retrieve for example list of affiliates, list of transactions, list of campaigns, etc. Constructor: Gpf_Rpc_Gridrequest($className, $methodName, $session) - creates grid request object. You have to specify name of the class + method to execute, and valid session object. Method name is usually “getRows”, class name depends on the grid you want to access. Methods: The following methods are availabl...

Gpf_Data_RecordSet

Recordset object contains recordsreturned by the system. Methods: _getSize()_ - returnsnumber of records in recordset Iterating through the recordset The easiest way to work with therecordset is to iterate through it. If you use _foreach_statement, you'll get every record as an object. You can use _get($columnName)_method to retrieve value of the column. Example of iterating through recordset: // get recordset from the grid $recordset = $grid->getRecordset(); // iterate through the records ...

Gpf_Rpc_Params

API communicates with PAP through JSON requests. It needs first to create the request as list of all parameters, then it transforms it into a JSON request that is sent to Post Affiliate Pro. Various classes in the API uses the Gpf_Rpc_Params object to pass it between them self. Gpf_Rpc_Server finally constructs the JSON using this Gpf_Rpc_Params. This object is used almost exclusively by other classes internally and user usually does not need to work with this object. However, sometimes you mig...

Examples of use

1. How do I get list of all banners? 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("http://localhost/scripts/server.php"); //replace http://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_Banners...

Gpf_Data_Grid

Grid object contains total number ofrecords in the database, and recordset object with list of allreturned records. Methods: _getTotalCount()_ – getstotal number of records in database (can be higher than number ofrecords returned) _getRecordset()_ –returns recordset object, that can be iterated by _foreach_PHP command to get the records. Example of using grid: //---------------------------------------------- // get recordset with list of affiliates $request = new Gpf_Rpc_GridRequest("Pap_Merc...