Introduction

2018-06-28 14:05:39
Renee
8624
Last edited by Taotao on 2018-07-02 10:56:01
Share links

1. API introduction

API is based on HTTP. All returned data is saved as .json.


ZenTaoPHP has two mechanisms of API. One is to call from the page, the other one is to call through getModel.


2. Call from the page

When visiting a page developed in ZenTaoPHP, change .html in URL to .json, then you will get the data in .json. For example,  http://pms.zentao.net/project-task-8.html. Change it to http://pms.zentao.net/project-task-8.json, and you will get the returned data in .json. If you use GET, change the parameter of t to json, http://pms.zentao.net/?m=project&f=task&t=json.


The returned data is done with json_encode twice. See the example as shown below"


$result = file_get_contents('http://pms.zentao.net/project-task-8.json'); 
$result = json_decode($($result);
if($result->result == 'success' and md5($result->data) == $result->md5)
{
    $data = json_decode($result->data);
    print_r($data);
}
First, check whether the result in the first level is right and whether md5 signature is right, then use json_decode to data.



3. Use getModle to call

It is limited to call from the page. It might return the data you don't want, so a getModel is offered in ZenTaoPHP to call.


First, add the privilege to the account that you will want it to call by the getModel. Then use getModel in API to get the open method of the model in any module.


Module name, method name and the parameters of the method are required in getModel. Use commas to separate each parameter. For example, key1=value1,key2=value2.


Take getUserBugPairs() in the module of Bug in ZenTao as an example.

  • GET: ?m=api&f=getModel&module=bug&methodName=getUserBugPairs&params=account=$account
  • PATH_INFO: api-getmodel-bug-getUserBugPairs-account=$account.json


Note

Use getModel to call is ONLY applied to ZenTao. Zsite or Zdoo is not supported yet.



If any questions, leave a message below. We will reply ASAP. Or shoot us an email at Renee@cnezsoft.com or liujun@cnezsoft.com.




Tiffany 2022-11-26 14:49:58 Reply
Hello
Information which you have shared is good but I am in trouble in implementing it.
philip 2022-11-28 15:38:38
Any problem you met please contact our support:support@easycorp.ltd
1/1
Write a Comment
Comment will be posted after it is reviewed.