Data model (JSON) description

The data transferred between client (request your script) and server (represented by scripts/server.php) are encoded in JSON format. This is the lowest level of communication.
You can use this level of communication if you cannot use our PHP based API (file PapApi.class.php) that allows you to create requests and process responses.
 

Pap_Api_Session (Gpf_Api_Session)

 
Login JSON request contains parameters:
- C: class name "Pap_Api_AuthService"
- M: method name "authenticate"
- fields: list of fields:
          - username
          - password
          - roleType: M for merchant username, A for affiliate username
          - isFromApi: should be always Y
          - apiVersion: version hash code from PapApi.class.php file, can be empty
 
example of login JSON request:
{"C":"Pap_Api_AuthService","M":"authenticate","fields":[["name","value","values","error"],["username","merchant@example.com",null,""],["password","demo",null,""],["roleType","M",null,""],["isFromApi","Y",null,""],["apiVersion","c278cce45ba296bc421269bfb3ddff74",null,""]]}
 
Login JSON response contains:
 
fields: list of fields in format ["name","value","values","error"]:
          - correspondsApi: Y or N means if API version hash code corresponds with version of Post Affiliate Pro
          - username
          - password
          - accountid
          - rememberMe
          - language
          - S: session ID (only this is important for all other API requests)
- success: Y or N means if username is correct
- message: info message about success or unsuccess
 
example JSON response:
{"fields":[["name","value","values","error"],["correspondsApi","N",null,""],["username","merchant@example.com",null,""],["password","demo",null,""],["accountid","",null,""],["rememberMe","N",null,""],["language","en-US",null,""],["S","6ble393nqp6tpla842bmmimop5",null,null]],"success":"Y","message":"User authenticated. Logging in."}
 

Gpf_Rpc_Request

 
base for all requests
 
request JSON contains parameters:
- C: class name
- M: method name
- S: session ID
(it can contains other parameters, depends on concrete request)
 
Example for loading count of rows from affiliate grid: (contains only classname, methodname and sessionid)
{"C":"Pap_Merchants_User_AffiliatesGrid","M":"getRowCount","S":"u2on93uhrr6jqbvjl32ncui4f0"}
Response for this request will look:
{"rows":[[]],"count":14}
count means count of rows from affiliate grid and rows is empty because we wanted to load only count
 
Another example of request for loading traffic stats data: (except classname, methodname and sessionid, contains list of filters also)
{"C":"Pap_Merchants_Reports_TrafficStatsData","M":"load","filters":[["datetime","DP",""],["rstatus","IN","A"],["campaignid","E","11111111"]],"S":"u2on93uhrr6jqbvjl32ncui4f0"}
Response for this request will look:
[["name","value"],["countImpressions","167"],["countClicks",99],["countSales",66],["sumSales",233004],["sumCommissions",44039.94]]
contains list of fields in format ["name","value"]
 

Gpf_Rpc_FormRequest

 
can be used to send form informations (extends the Gpf_Rpc_Request)
 
request JSON contains parameters:
- C: class name (suffix Form)
- M: method name (generally add, load, save)
- fields: list of form fields in format ["name","value"]
- S: session ID
 
Example of request for adding affiliate into commission group:
{"C":"Pap_Features_CommissionGroups_AffiliateGroupForm", "M":"add", "fields":[["name","value"],["Id",""],["userid","ceba10bf"],["rstatus","A"],["note",""],["commissiongroupid","a17209a9"],["campaignid","11111111"]],"S":"u2on93uhrr6jqbvjl32ncui4f0"}
Response for this request contains:
- fields: list of fields in format ["name","value","values","error"]
- success: Y or N
- message: info message about success or unsuccess
{"fields":[["name","value","values","error"],["Id","73c468b0",null,""],["userid","ceba10bf",null,""],["rstatus","A",null,""],["note","",null,""],["commissiongroupid","a17209a9",null,""],["campaignid","11111111",null,null],["usercommgroupid","73c468b0",null,""],["dateadded","2012-04-27 09:12:23",null,""]],"success":"Y","message":"Affiliate was successfully added"}
 

Gpf_Rpc_GridRequest

 
can be used to retrieve list of affiliates, list of transactions, list of campaigns, etc.
 
request JSON contains parameters:
- C: class name (suffix Grid)
- M: method name (generally getRows)
- sort_col: name of sorting column
- sort_asc: false or true
- offset: skipped rows
- limit: number of rows
- filters: list of filters for data (this field is not mandatory, if it is missing grid use only default filter)
- columns: list of column namesf in format ["name"] (this field is not mandatory, if it is missing response will contains default columns for grid)
- S: session ID
 
Example of request for loading affiliates grid rows:
{"C":"Pap_Merchants_User_AffiliatesGrid", "M":"getRows", "sort_col":"dateinserted", "sort_asc":false, "offset":0, "limit":30,"filters":[["dateinserted","DP","TY"],["rstatus","IN","A,D,P"]], "columns":[["id"],["id"],["refid"],["userid"],["username"],["firstname"],["lastname"],["rstatus"],["parentuserid"],["parentusername"],["parentfirstname"],["parentlastname"],["dateinserted"],["actions"]], "S":"u2on93uhrr6jqbvjl32ncui4f0"}
Response for this request contains:
- rows: all loaded data (first row contains names of columns)
- count: number of loaded rows
{"rows":[["id","userid","refid","firstname","lastname","username","rstatus","dateinserted","parentuserid","parentusername","parentfirstname","parentlastname"],["96beb96f","96beb96f","testaff","Test","Affiliate","affiliate@example.com","A","2012-03-08 07:13:27",null,null,null,null],["761b2a5d","761b2a5d","aff","test","affiliate","test@affiliate.com","A","2012-02-06 02:33:30",null,null,null,null]],"count":2}

 

Multirequest

 
If you want to send many requests at one time, you can merge them into one request (multirequest). Multirequest is request to class: "Gpf_Rpc_Server" method "run" with parameter "requests". If requests need be authenticated, you dont need to insert session id into every request in multirequest, it is enough to put session ID in multirequest as parameter "S".
 
Example JSON (two requests in one multirequest):
{"C":"Gpf_Rpc_Server", "M":"run", "requests":[{"C":"Pap_Merchants_User_AffiliatesGrid", "M":"getRows", "sort_col":"dateinserted", "sort_asc":false, "offset":0, "limit":30, "columns":[["id"],["id"],["refid"],["userid"],["username"],["firstname"],["lastname"],["rstatus"],["parentuserid"],["parentusername"],["parentfirstname"],["parentlastname"],["dateinserted"],["actions"]]},{"C":"Pap_Features_CommissionGroups_AffiliateGroupForm", "M":"add", "fields":[["name","value"],["Id",""],["userid","ceba10bf"],["rstatus","A"],["note",""],["commissiongroupid","a17209a9"],["campaignid","11111111"]]}], "S":"r3egjfj4d2te8aou4k37rckkr7"}
 
Example of using in PHP script: Data model JSON example of use
 
×