Libr

安装运行

API 调用

1 注册 POST: http://127.0.0.1:3000/api/v1/sign_up

  • 参数:
    • user[email]
    • user[password]
    • user[password_confirmation]
  • 返回结果
{
  "user": {
    "id": 10,
    "name": "test5",
    "email": "test5@qq.com",
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbiI6ImU3M2YzYTljMTIxMjVkNDViNjJlNjkxNjQ4MjgyNGVmIn0.Rv_DkYEDWOIhObnTjC_8N8L-BACm8cFCOSqEgSmPUDc"
  }
}

2 登录 POST: http://127.0.0.1:3000/api/v1/sign_in

  • 参数:
  • user[email]
  • user[password]
  • 返回结果:
 {
   "user": {
     "id": 3,
     "name": null,
     "email": "wahyd4@qq.com",
     "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbiI6IjU0MGU4OTU4ODg3ZmI1MGI5YTA5YzI4MjQ2NTZlYTRlIn0.XQBWCNRYVdDvZwuBtafCyOkNpP8FEzwRqk8AhaHlaFc"
   }
 }

3 提交分享资源 POST: http://localhost:3000/api/v1/posts

  • 参数
  • 需要登录 传Authorization header
  • url 网址
  • type article 或者 web_page
  • description 可选
  • 返回
  {
    "id": 32,
    "user_id": 3,
    "sharable_id": 3,
    "sharable_type": "WebPage",
    "created_at": "2015-08-04T00:33:25.735+08:00",
    "updated_at": "2015-08-04T00:33:25.735+08:00",
    "description": "这是一个特别cool的github 项目",
    "sharable": {
      "id": 3,
      "name": null,
      "url": "http://mp.weixin.qq.com/s?__biz=MzA4NjAzMjEyOA==&mid=207485444&idx=1&sn=c0d5e1b2399fffbcdc5a5065eea52af8",
      "created_at": "2015-08-04T00:33:25.627+08:00",
      "updated_at": "2015-08-04T00:33:25.627+08:00",
      "processed": false,
      "view_account": 0
    }
  }

4 未注册用户首页数据 GET http://localhost:3000/api/v1/posts

  • 参数
  • 返回
  [
    {
      "description": "这是我看到底第一篇他写的文章",
      "sharable_type": "Article",
      "sharable": {
        "view_account": 0,
        "url": "http://www.jianshu.com/p/bfbc77eecdb0",
        "title": null
      }
    },      
    {
      "description": "到底能不能成功啊,我去",
      "sharable_type": "Article",
      "sharable": {
        "view_account": 0,
        "url": "http://www.cnbeta.com/articles/416787.htm",
        "title": null
      }
    },
    {
      "description": "这是一个特别cool的github 项目",
      "sharable_type": "WebPage",
      "sharable": {
        "view_account": 0,
        "url": "https://github.com/sparklemotion/mechanize",
        "title": "sparklemotion/mechanize · GitHub"
      }

注意

  • 注意,API返回结果中的token是利用JWT 技术加密的token,密钥是每个用户的email
  • jwt
S
Description
No description provided
Readme
716 KiB
Languages
Ruby 67.7%
SCSS 17%
HTML 15.1%
Dockerfile 0.1%