[关闭]
@heavysheep 2017-10-18T15:45:47.000000Z 字数 8086 阅读 1015

直播api

未分类


公共聊天

接口send_message
说明:基本维持原来的数据类型,砍掉了team_id等,增加live_id。
示例数据

  1. test_data = {
  2. "fromUserId": "52c3f1065f94ed491327cd88", # 用户id
  3. "live_id": "00009028b5f68419ab9c40a1b0e138b6dcbee3f5", # live_id
  4. "chatroom_id": json.dumps(["00009097f7b32c02669748d6a9a52e2f435be845"]), # json形式chatroom_id,列表格式
  5. "message_class": "interaction", # 数据类型,后续不需要存的数据可直接约定在此
  6. "message_type": "TxtMsg",
  7. "site_id": "2432383526fd39e5ddf84a2588292ad5ac494e25",
  8. "content": json.dumps({"content": {"id": "52c3f1065f94ed491327cd88",
  9. "name": "ZGlhbnhpbmxpdQ==",
  10. "img": "55c86bf5b4b706624aed889c",
  11. "msg": "MTIzMTIz",
  12. "send_time": 1503979247842,
  13. "team_id": "26235843f9373aa65e6144a8b308d234cecc8463",
  14. "msg_type": "chat"}})
  15. # json形式content,双层嵌套

此时会向md5哈希后的chatroom_id即423401501e5893b32dc9d2bac0d5f165以from_user_id发送消息类型为RC:TxtMsg的json化数据:
向融云发送的数据

  1. {'fromUserId': '52c3f1065f94ed491327cd88',
  2. 'chatroom_id': u'00009097f7b32c02669748d6a9a52e2f435be845',
  3. u'name': u'ZGlhbnhpbmxpdQ==',
  4. u'img': u'55c86bf5b4b706624aed889c',
  5. 'site_id': '2432383526fd39e5ddf84a2588292ad5ac494e25',
  6. 'message_class': 'interaction',
  7. 'state': 0,
  8. u'send_time': 1503979247842L,
  9. u'msg': u'MTIzMTIz',
  10. u'team_id': u'26235843f9373aa65e6144a8b308d234cecc8463',
  11. 'message_type': 'TxtMsg',
  12. u'id': u'52c3f1065f94ed491327cd88',
  13. u'msg_type': u'chat'}

接口返回

  1. {u'code': 200} # 当返回200时一切正常,返回非200情况为融云错误,其他错误返回svr_send_message开头的字符串

教师操作

接口send_message
说明:按要求原来的数据类型,将content字段提至外层,砍掉了team_id等,live_time等,增加live_id。
示例数据

  1. test_data = {
  2. "fromUserId": "52c3f1065f94ed491327cd88",
  3. "chatroom_id": json.dumps(["00009097f7b32c02669748d6a9a52e2f435be845"]),
  4. "message_class": "ppt_single",
  5. "message_type": "TxtMsg",
  6. "live_id": "00009028b5f68419ab9c40a1b0e138b6dcbee3f5",
  7. "site_id": "2432383526fd39e5ddf84a2588292ad5ac494e25",
  8. "id": "52c3f1065f94ed491327cd88",
  9. "index": 3,
  10. "name": "ZGlhbnhpbmxpdQ==",
  11. "msg": "MTIzMTIz",
  12. "url": "123456",
  13. "count": 6,
  14. "send_time": 1503979247842,
  15. "msg_type": "chat"
  16. }

此时会向md5哈希后的chatroom_id即423401501e5893b32dc9d2bac0d5f165以from_user_id发送消息类型为RC:ppt_single的json化数据:
向融云发送的数据

  1. {'fromUserId': '52c3f1065f94ed491327cd88',
  2. 'msg_id': '59e7002ee3ae9a31f42e7203',
  3. 'msg_type': 'chat',
  4. 'chapter_resource_id': u'83029656296ac93502e146d3bd18640249125f9b', 'live_time': 429063.37,
  5. 'message_class': 'ppt_single',
  6. 'id': '52c3f1065f94ed491327cd88',
  7. 'count': 6, 'index': 3,
  8. 'url': '123456',
  9. 'message_type': 'TxtMsg'}

接口返回

  1. {u'code': 200} # 当返回200时一切正常,返回非200情况为融云错误,其他错误返回svr_send_message开头的字符串

获取公聊数据

接口message_list
说明:基本维持原来的数据类型,因为业务和结构变动,支持参数变少,目前支持的筛选条件message_class、page、limit和sort,默认时间正序索引
示例数据

  1. test_data = {
  2. "toUserId": json.dumps(["00009097f7b32c02669748d6a9a52e2f435be845"]), # 未哈希过的chatroom_id
  3. "message_class": json.dumps(["interaction"]), # json化的列表,其中为所需要的类型
  4. "page": 1, # 页数,从1开始,不填默认为1
  5. "limit": 10 # 页数,不填默认为20
  6. "sort": -1 # 反向排序,不需要可以不填
  7. }

则接口返回

  1. [
  2. {
  3. u'fromUserId': u'52c3f1065f94ed491327cd88',
  4. u'chatroom_id': u'00009097f7b32c02669748d6a9a52e2f435be845',
  5. u'name': u'ZGlhbnhpbmxpdQ==',
  6. u'msg_type': u'chat',
  7. u'state': 0,
  8. u'message_type': u'TxtMsg',
  9. u'live_time': 0,
  10. u'site_id': u'2432383526fd39e5ddf84a2588292ad5ac494e25',
  11. u'message_class': u'interaction',
  12. u'img': u'55c86bf5b4b706624aed889c',
  13. u'team_id': u'26235843f9373aa65e6144a8b308d234cecc8463',
  14. u'send_time': 1503979247842L,
  15. u'msg': u'MTIzMTIz',
  16. u'json_content': [
  17. u'{
  18. "content": {
  19. "name": "ZGlhbnhpbmxpdQ==",
  20. "img": "55c86bf5b4b706624aed889c",
  21. "team_id": "26235843f9373aa65e6144a8b308d234cecc8463",
  22. "send_time": 1503979247842,
  23. "msg": "MTIzMTIz",
  24. "id": "52c3f1065f94ed491327cd88",
  25. "msg_type": "chat"
  26. }
  27. }'
  28. ],
  29. u'id': u'52c3f1065f94ed491327cd88',
  30. u'add_time': datetime.datetime(2017,10,16,17,46,42,804000)
  31. },
  32. {
  33. u'fromUserId': u'52c3f1065f94ed491327cd88',
  34. u'chatroom_id': u'00009097f7b32c02669748d6a9a52e2f435be845',
  35. u'name': u'ZGlhbnhpbmxpdQ==',
  36. u'img': u'55c86bf5b4b706624aed889c',
  37. u'json_content': [
  38. u'{
  39. "content": {
  40. "name": "ZGlhbnhpbmxpdQ==",
  41. "img": "55c86bf5b4b706624aed889c",
  42. "team_id": "26235843f9373aa65e6144a8b308d234cecc8463",
  43. "send_time": 1503979247842,
  44. "msg": "MTIzMTIz",
  45. "id": "52c3f1065f94ed491327cd88",
  46. "msg_type": "chat"
  47. }
  48. }'
  49. ],
  50. u'live_time': 0,
  51. u'site_id': u'2432383526fd39e5ddf84a2588292ad5ac494e25',
  52. u'message_class': u'interaction',
  53. u'state': 0,
  54. u'send_time': 1503979247842L,
  55. u'msg': u'MTIzMTIz',
  56. u'team_id': u'26235843f9373aa65e6144a8b308d234cecc8463',
  57. u'message_type': u'TxtMsg',
  58. u'id': u'52c3f1065f94ed491327cd88',
  59. u'msg_type': u'chat',
  60. u'add_time': datetime.datetime(2017,10,16,18,0,40,56000)
  61. },
  62. {
  63. u'fromUserId': u'52c3f1065f94ed491327cd88',
  64. u'chatroom_id': u'00009097f7b32c02669748d6a9a52e2f435be845',
  65. u'name': u'ZGlhbnhpbmxpdQ==',
  66. u'img': u'55c86bf5b4b706624aed889c',
  67. u'live_time': 0,
  68. u'site_id': u'2432383526fd39e5ddf84a2588292ad5ac494e25',
  69. u'message_class': u'interaction',
  70. u'state': 0,
  71. u'send_time': 1503979247842L,
  72. u'msg': u'MTIzMTIz',
  73. u'team_id': u'26235843f9373aa65e6144a8b308d234cecc8463',
  74. u'message_type': u'TxtMsg',
  75. u'id': u'52c3f1065f94ed491327cd88',
  76. u'msg_type': u'chat',
  77. u'add_time': datetime.datetime(2017,10,16,18,1,25,162000)
  78. },
  79. {
  80. u'fromUserId': u'52c3f1065f94ed491327cd88',
  81. u'chatroom_id': u'00009097f7b32c02669748d6a9a52e2f435be845',
  82. u'name': u'ZGlhbnhpbmxpdQ==',
  83. u'img': u'55c86bf5b4b706624aed889c',
  84. u'live_time': 0,
  85. u'site_id': u'2432383526fd39e5ddf84a2588292ad5ac494e25',
  86. u'message_class': u'interaction',
  87. u'state': 0,
  88. u'send_time': 1503979247842L,
  89. u'msg': u'MTIzMTIz',
  90. u'team_id': u'26235843f9373aa65e6144a8b308d234cecc8463',
  91. u'message_type': u'TxtMsg',
  92. u'id': u'52c3f1065f94ed491327cd88',
  93. u'msg_type': u'chat',
  94. u'add_time': datetime.datetime(2017,10,18,14,55,8,357000)
  95. },
  96. {
  97. u'fromUserId': u'52c3f1065f94ed491327cd88',
  98. u'chatroom_id': u'00009097f7b32c02669748d6a9a52e2f435be845',
  99. u'name': u'ZGlhbnhpbmxpdQ==',
  100. u'img': u'55c86bf5b4b706624aed889c',
  101. u'live_time': 0,
  102. u'site_id': u'2432383526fd39e5ddf84a2588292ad5ac494e25',
  103. u'message_class': u'interaction',
  104. u'state': 0,
  105. u'send_time': 1503979247842L,
  106. u'msg': u'MTIzMTIz',
  107. u'team_id': u'26235843f9373aa65e6144a8b308d234cecc8463',
  108. u'message_type': u'TxtMsg',
  109. u'id': u'52c3f1065f94ed491327cd88',
  110. u'msg_type': u'chat',
  111. u'add_time': datetime.datetime(2017,10,18,14,59,38,355000)
  112. },
  113. {
  114. u'fromUserId': u'52c3f1065f94ed491327cd88',
  115. u'chatroom_id': u'00009097f7b32c02669748d6a9a52e2f435be845',
  116. u'name': u'ZGlhbnhpbmxpdQ==',
  117. u'img': u'55c86bf5b4b706624aed889c',
  118. u'site_id': u'2432383526fd39e5ddf84a2588292ad5ac494e25',
  119. u'message_class': u'interaction',
  120. u'state': 0,
  121. u'send_time': 1503979247842L,
  122. u'msg': u'MTIzMTIz',
  123. u'team_id': u'26235843f9373aa65e6144a8b308d234cecc8463',
  124. u'message_type': u'TxtMsg',
  125. u'id': u'52c3f1065f94ed491327cd88',
  126. u'msg_type': u'chat',
  127. u'add_time': datetime.datetime(2017,10,18,15,19,48,333000)
  128. },
  129. {
  130. u'fromUserId': u'52c3f1065f94ed491327cd88',
  131. u'chatroom_id': u'00009097f7b32c02669748d6a9a52e2f435be845',
  132. u'name': u'ZGlhbnhpbmxpdQ==',
  133. u'img': u'55c86bf5b4b706624aed889c',
  134. u'site_id': u'2432383526fd39e5ddf84a2588292ad5ac494e25',
  135. u'message_class': u'interaction',
  136. u'state': 0,
  137. u'send_time': 1503979247842L,
  138. u'msg': u'MTIzMTIz',
  139. u'team_id': u'26235843f9373aa65e6144a8b308d234cecc8463',
  140. u'message_type': u'TxtMsg',
  141. u'id': u'52c3f1065f94ed491327cd88',
  142. u'msg_type': u'chat',
  143. u'add_time': datetime.datetime(2017,10,18,15,22,57,918000)
  144. }
  145. ]

获取所有教师操作数据

接口live_comm_list
说明:基本维持原来的数据类型,因为业务和结构变动,支持参数变少,目前仅支持筛选条件message_class,默认时间正序排序
示例数据

  1. test_data = {
  2. "toUserId": json.dumps(["00009097f7b32c02669748d6a9a52e2f435be845"]),
  3. "message_class": json.dumps(["ppt_single"]),
  4. }

则接口返回

  1. [
  2. {
  3. u'fromUserId': u'52c3f1065f94ed491327cd88',
  4. u'chapter_resource_id': u'83029656296ac93502e146d3bd18640249125f9b',
  5. u'msg_id': u'59e48237e3ae9a3960a01aa9',
  6. u'msg_type': u'chat',
  7. u'count': 6,
  8. u'url': u'123456',
  9. u'index': 3,
  10. u'live_time': 265744.5,
  11. u'message_class': u'ppt_single',
  12. u'message_type': u'TxtMsg',
  13. u'id': u'52c3f1065f94ed491327cd88',
  14. u'add_time': datetime.datetime(2017,10,16,17,56,8,720000)
  15. },
  16. {
  17. u'fromUserId': u'52c3f1065f94ed491327cd88',
  18. u'chapter_resource_id': u'83029656296ac93502e146d3bd18640249125f9b',
  19. u'msg_id': u'59e6fed4e3ae9a2958398200',
  20. u'msg_type': u'chat',
  21. u'count': 6,
  22. u'url': u'123456',
  23. u'index': 3,
  24. u'live_time': 428717.39,
  25. u'message_class': u'ppt_single',
  26. u'message_type': u'TxtMsg',
  27. u'id': u'52c3f1065f94ed491327cd88',
  28. u'add_time': datetime.datetime(2017,10,18,15,12,21,487000)
  29. },
  30. {
  31. u'fromUserId': u'52c3f1065f94ed491327cd88',
  32. u'chapter_resource_id': u'83029656296ac93502e146d3bd18640249125f9b',
  33. u'msg_id': u'59e7002ee3ae9a31f42e7203',
  34. u'msg_type': u'chat',
  35. u'count': 6,
  36. u'url': u'123456',
  37. u'index': 3,
  38. u'live_time': 429063.37,
  39. u'message_class': u'ppt_single',
  40. u'message_type': u'TxtMsg',
  41. u'id': u'52c3f1065f94ed491327cd88',
  42. u'add_time': datetime.datetime(2017,10,18,15,18,7,577000)
  43. }
  44. ]

其他接口不知道是否被废弃,我还没进行测试,有什么需要随时跟我说

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注