# open_demo **Repository Path**: diggme/open_demo ## Basic Information - **Project Name**: open_demo - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-06-20 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 开发文档 # 配置 - app_key: xxxxxx - app_key: xxxxxxxxxxxx - channel_id: xxx # 流程 - 1.支付完成之后(跟据自身的业务,来进行开发) - 2.调用 /api/v1/open/token接口,获取access_token(后面所有接口,都需要token认证) - 3.调用 /api/v1/channel/test/code接口,获取in_code - 4.调用 /api/v1/channel/notify/payCb接口,订单状态回调 (支付成功) - 5.加载或跳转到测试入口: https://wx.diggme.cn/channel/entry?channel_id={channel_id}&test_id={test_id}&in_code={in_code}&is_iframe=1 # 接口 - 地址:https://api.diggme.cn ### 1. GET: /api/v1/open/token 获取token ##### 请求方式:GET ##### 参数 ``` grant_type: (str),client_credential app_key: (str),xxxxx app_secret: (str),xxxxxxxxxxx ``` ##### 返回格式 ``` { "http_status": 200, "status": true, "data": { "access_token": "xxxxxxxxxxx", "expire_in": 7200, }, "meta": null, "msg": null } ``` # 注意:以下接口都要设置HTTP头字段 Authorization: (str),token字串 ### 1. GET: /api/v1/channel/test/category/list 获取分类列表 ##### 请求方式:GET ##### 参数 ``` 无 ``` ##### 返回格式 ``` { "http_status": 200, "status": true, "data": [ { "id": 111, //分类Id "name": "工作" "img": "http://img.diggme.cn/2017/06/02/1a3ffb374e31f485ebf79a1146f9a9ff.png", //大图 "pic": "http://img.diggme.cn/2018/04/08/13c150ca5bc780dfc7f66efdccd90bbf.jpg", //小图 "brift": "你还有多少勇气敢去爱?", //简述 }, { "id": 112, //分类Id "name": "爱情" "img": "http://img.diggme.cn/2017/06/02/1a3ffb374e31f485ebf79a1146f9a9ff.png", //大图 "pic": "http://img.diggme.cn/2018/04/08/13c150ca5bc780dfc7f66efdccd90bbf.jpg", //小图 "brift": "你还有多少勇气敢去爱?", //简述 }, ], "meta": null, "msg": null } ``` ### 2. GET: /api/v1/channel/test/list 获取测试列表 ##### 请求方式:GET ##### 参数 ``` category_id: (int), 分类ID(默认为0) flag: (str), top置顶,new最新 keyword: (str), 关键词 page: (int),页数 size: (int),数量 ``` ##### 返回格式 ``` { "http_status": 200, "status": true, "data": [ { "id": 10, //测试ID "title": "恋爱勇气评估" "img": "http://img.diggme.cn/2017/06/02/1a3ffb374e31f485ebf79a1146f9a9ff.png", "pic": "http://img.diggme.cn/2018/04/08/13c150ca5bc780dfc7f66efdccd90bbf.jpg", "price": 9.9, "brift": "你还有多少勇气敢去爱?", "content": "内容...", ... }, { "id": 10, //测试ID "title": "恋爱勇气评估" "img": "http://img.diggme.cn/2017/06/02/1a3ffb374e31f485ebf79a1146f9a9ff.png", "pic": "http://img.diggme.cn/2018/04/08/13c150ca5bc780dfc7f66efdccd90bbf.jpg", "price": 9.9, "brift": "你还有多少勇气敢去爱?", "content": "内容...", ... }, ], "meta": null, "msg": null } ``` ### 3. GET: /api/v1/channel/test/detail 获取测试详情 ##### 请求方式:GET ##### 参数 ``` test_id: (int),测试ID ``` ##### 返回格式 ``` { "http_status": 200, "status": true, "data": { "id": 10, //测试ID "title": "恋爱勇气评估", //标题 "img": "http://img.diggme.cn/2017/06/02/1a3ffb374e31f485ebf79a1146f9a9ff.png", //大图 "pic": "http://img.diggme.cn/2018/04/08/13c150ca5bc780dfc7f66efdccd90bbf.jpg", //小图 "price": 9.9, "brift": "你还有多少勇气敢去爱?", //简述 "content": "内容...", // 详情 ... }, "meta": null, "msg": null } ``` ### 4. GET: /api/v1/channel/test/code 获取in_code ##### 请求方式:GET ##### 参数 ``` test_id: (int),测试ID no: (str), 订单号 ``` ##### 返回格式 ``` { "http_status": 200, "status": true, "data": { "code": "xxxxxxxxxxxxxx-xxxxxxx" }, "meta": null, "msg": null } ``` ### 5. GET: /api/v1/channel/test/codeStatus 查询in_code状态 ##### 请求方式:GET ##### 参数 ``` test_id: (int),测试ID in_code: (str), 测试订单兑换码 ``` ##### 返回格式 ``` { "http_status": 200, "status": true, "data": { "is_order_pay": 1, //1已支付,0未支付, "is_test_finish": //1已测,0未测, "test_id": 10, "order_id": xxxxx, ... }, "meta": null, "msg": null } ``` ### 6. POST: /api/v1/channel/notify/payCb 订单状态回调 (支付成功) ##### 请求方式:POST ##### 参数 ``` encrypt_data: (str),加密数据(加密方式 aes_cfb_256(secret="your app_secret",iv="",data="{"in_code":"xxxx-xxx","status":"success"}") ``` 如: ``` $inCode, 'status' => 'success' ]; $appSecret = 'xxxxxxxxxxxxx'; $encryptData = @openssl_encrypt(json_encode($data), 'aes-256-cfb', $appSecret) ?> ``` ##### 返回格式 ``` { "http_status": 200, "status": true, //true成功,false失败 "data": null, "meta": null, "msg": null } ```