Update doc and readme

This commit is contained in:
Frederic Guillot
2016-01-23 10:52:55 -05:00
parent ad8fcf035a
commit 94207cf8ea
3 changed files with 46 additions and 95 deletions

View File

@@ -34,62 +34,30 @@ Response from the server:
Example with Python
-------------------
Here a basic example written in Python to create a task:
```python
#!/usr/bin/env python
import requests
import json
def main():
url = "http://demo.kanboard.net/jsonrpc.php"
api_key = "be4271664ca8169d32af49d8e1ec854edb0290bc3588a2e356275eab9505"
headers = {"content-type": "application/json"}
payload = {
"method": "createTask",
"params": {
"title": "Python API test",
"project_id": 1
},
"jsonrpc": "2.0",
"id": 1,
}
response = requests.post(
url,
data=json.dumps(payload),
headers=headers,
auth=("jsonrpc", api_key)
)
if response.status_code == 401:
print "Authentication failed"
else:
result = response.json()
assert result["result"] == True
assert result["jsonrpc"]
assert result["id"] == 1
print "Task created successfully!"
if __name__ == "__main__":
main()
```
Run this script from your terminal:
You can use the [official Python client for Kanboard](https://github.com/kanboard/kanboard-api-python):
```bash
python jsonrpc.py
Task created successfully!
pip install kanboard
```
Here an example to create a project and a task:
```python
from kanboard import Kanboard
kb = Kanboard("http://localhost/jsonrpc.php", "jsonrpc", "your_api_token")
project_id = kb.create_project(name="My project")
task_id = kb.create_task(project_id=project_id, title="My task title")
```
There are more examples on the [official website](https://github.com/kanboard/kanboard-api-python).
Example with a PHP client
-------------------------
I wrote a simple [Json-RPC Client/Server library in PHP](https://github.com/fguillot/JsonRPC), here an example:
You can use this [Json-RPC Client/Server library for PHP](https://github.com/fguillot/JsonRPC), here an example:
```php
<?php