Skip to content
Insane edited this page Sep 9, 2015 · 1 revision

1. GET /kindergarten/:kg/session/:topicId/record


GET https://stage2.cocobabys.com/kindergarten/1003/session/1_1396844597394/record

topicId是小孩id from=起始id,不包括 to=结束id,不包括

[
{"topic":"1_1396844597394","timestamp":112312313123,"id":1,"content":"老师你好,我们家王大侠怎么样。","media":{"url":"http://suoqin-test.u.qiniudn.com/FgPmIcRG6BGocpV1B9QMCaaBQ9LK","type":"image"},"sender":{"id":"2_1003_1396844438388","type":"p"}},{"topic":"1_1396844597394","timestamp":212313313123,"id":2,"content":"家长你好,你家王大侠最近没有来。","media":{"url":"http://suoqin-test.u.qiniudn.com/Fget0Tx492DJofAy-ZeUg1SANJ4X","type":"image"},"sender":{"id":"3_1003_1396357639003","type":"t"}},{"topic":"1_1396844597394","timestamp":312314313123,"id":3,"content":"娃他妈,怎么回事。","media":{"url":"","type":"image"},"sender":{"id":"2_1003_4","type":"p"}}
]

senderid是发送者的id,可以是parent_id或者employee_id,sendertype是't'(老师)或者'p'(家长)。创建时默认为't'。 可以通过employee接口查询老师的信息

2. POST /kindergarten/:kg/session/:topicId/record


POST https://stage2.cocobabys.com/kindergarten/1003/session/1_1396844597394/record

request payload:

{"topic":"1_1396844597394","content":"我再说两句","media":{"url":"http://suoqin-test.u.qiniudn.com/FgPmIcRG6BGocpV1B9QMCaaBQ9LK","type":"image"},"sender":{"id":"2_1003_1396844438388","type":"p"}}

参数retrieve_recent_from保证服务器在收到新消息时直接返回最近的25条信息。工作原理是: 例:retrieve_recent_from=100 POST https://www.cocobabys.com/kindergarten/93740362/session/123456789/record?retrieve_recent_from=100 返回的结果为:返回服务器端包括最新创建的信息(假设编号为120)在内的,从id=101开始到id=120的信息,id从大到小排列,如果符合条件的信息超过25条只返回25条,因此可能新创建的信息不会返回。

3. GET /kindergarten/:kg/session/:topicId/reader/:readerId


http://localhost:9000/kindergarten/93740362/session/1_93740362_9982/reader/3_93740362_9972

the client side should compare the session_id in response with last received session's id parameter: topicId:是小孩id readerId:是老师id,未来可能扩展到家长id

response json:

{"school_id":93740362,"reader":"3_93740362_9972","topic":"1_93740362_9982","session_id":0,"timestamp":0}

4.POST /kindergarten/:kg/session/:topicId/reader/:readerId


Tell the backend server that the reader readerId has read the session session_id with the topic 1_93740362_9982.

request payload:

{"school_id":93740362,"reader":"3_93740362_9972","topic":"1_93740362_9982","session_id":100}

response json:

{"school_id":93740362,"reader":"3_93740362_9972","topic":"1_93740362_9982","session_id":100,"timestamp":123123131232}

Clone this wiki locally