找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索本站精品资源

首页 教程频道 小程序开发 查看内容

晓想REST API :小晓想开发的一个REST API

作者:模板之家 2018-2-7 11:26 9576人关注

为小晓想开发的一个REST API 用于小程序接口试调,开发。 REST API 资源汇总 https://tinyapp.sparklog.com/ // = apis 返回当前所有资源接口 微信登录 GET: `https://tinyapp.sparklog.com/session/?code=${code}ne

为小晓想开发的一个REST API

用于小程序接口试调,开发。

REST API 资源汇总

https://tinyapp.sparklog.com/   // => apis

返回当前所有资源接口

微信登录

GET: `https://tinyapp.sparklog.com/session/?code=${code}&newteo=${newteo}`   // => token

返回token

参数以query的形式传递,即: ?key1=value1&key2=value2

接收参数如下:

{
  code,          // required!
  newteo,        // required!
  encryptedData  // required!
  iv             // required!
}

code -> 小程序APIwx.login()返回的code

iv -> 小程序APIwx.getUserInfo()返回的iv

encryptedData -> 小程序APIwx.getUserInfo()返回的encryptedData

newteo -> 约定盐

上传音频

POST: `https://tinyapp.sparklog.com/upload/?token=${token}`

只接收mutipart/form-data格式
创建成功返回JSON如下:

{
  "fieldname": "imagination",
  "originalname": "1A1A9BF9-6594-446E-8CA9-C6AEBC941CB6.png",
  "encoding": "7bit",
  "mimetype": "image/png",
  "destination": "uploads/",
  "filename": "da39a3ee5e6b4b0d3255bfef95601890afd807091A1A9BF9-6594-446E-8CA9-C6AEBC941CB6.png",
  "path": "uploads/da39a3ee5e6b4b0d3255bfef95601890afd807091A1A9BF9-6594-446E-8CA9-C6AEBC941CB6.png",
  "size": 116825
}

创建想法

POST: `https://tinyapp.sparklog.com/imagination/?token=${token}`

接收四个必填参数${src} ${title} ${description} ${duration}
数据模型如下:

{
  openId: {type: String, required: true},
  src: {type: String, required: true},
  userId: String,
  category: String,
  description: {type: String, required: true},
  title: {type: String, required: true},
  duration: {type: Number, required: true},
  like: {type: Number, default: 0},
  heard: {type: Number, default: 0},
  createdAt: {type: Date, default: new Date()},
  updatedAt: Date,
}

更新想法

PUT: `https://tinyapp.sparklog.com/imagination/:id/?token=${token}` 

接收任意更新字段,成功后返回更新资源

删除想法

DELETE: `https://tinyapp.sparklog.com/imagination/:id/?token=${token}` 

成功返回空数组

获取单一想法

GET: `https://tinyapp.sparklog.com/imagination/:id/?token=${token}` 

成功返回单一想法资源

获取想法列表

GET: `https://tinyapp.sparklog.com/imaginations/?token=${token}&per=${per}&page=${page}` 

接收query可选参数${per} ${page}

{
  token,          // required!
  per,            // optional default: 10 
  page            // optional 
}

成功返回想法资源列表如下:

[
  {
    "_id": "583c25ff257f476ea33056fb",
    "__v": 0,
    "createdAt": "2016-11-28T12:40:51.508Z",
    "heard": 0,
    "like": 0
  },
  {
    "_id": "583c2625e70d066eb2230a93",
    "__v": 0,
    "createdAt": "2016-11-28T12:42:12.936Z",
    "heard": 0,
    "like": 0
  },
  {
    "_id": "583e998611d292798a2bba21",
    "title": "ooxx",
    "src": "ooxx",
    "duration": 400,
    "description": "ooxxoxx",
    "__v": 0,
    "createdAt": "2016-11-30T09:12:59.896Z",
    "heard": 0,
    "like": 0
  },
  {
    "_id": "583ea7f48ed53979a20344fc",
    "title": "ooxx",
    "src": "ooxx",
    "duration": 400,
    "description": "ooxxoxx",
    "__v": 0,
    "createdAt": "2016-11-30T09:24:37.736Z",
    "heard": 0,
    "like": 0
  }
]

声音(微信摇一摇)

GET: `https://tinyapp.sparklog.com/audio/?token=${token}`      // => mp3

返回声音播放资源,请求时需将token以query的形式传参

所有用户

GET: `https://tinyapp.sparklog.com/users/?token=${token}&per=${per}&page=${page}`    // => all users

返回所有用户列表,默认返回前十条资源

接收参数如下:

{
  token,          // required!
  per,            // optional default: 10 
  page            // optional 
}

per -> 自定义加载数量

page -> 翻页(页码)

单一用户


路过

雷人

握手

鲜花

鸡蛋
原作者: 模板之家 来自: 网络收集

全部回复(0)