Webhook - 友好速搭 -- 开发文档

友好速搭

开放 API
使用说明 获取授权 全部 API 特殊 API 开放功能

Webhook

Webhook

参考智能通知介绍。

Webhook 属性

    • address
    •   {"address": "http://www.example.com/create_product" }
      
      Webhook 接收通知的地址。
    • created_at
    •   { "created_at" : "2014-09-01T00:00:01.987+08:0" }
      
      Webhook 的创建时间。API返回的日期格式为ISO 8601
    • id
    •   { "id" : 2 }
      
      Webhook 的唯一整型标识,在整个友好速搭系统中,不会有两个相同ID的 Webhook。
    • updated_at
    •   { "updated_at": "2015-01-25T22:31:06.155+08:00" }
      
      Webhook 的最近一次修改时间。API返回的日期格式为ISO 8601
    • content_type
    •   { "content_type": "application/json" }
      
      Webhook 的通知数据类型。默认使用的是 http post 的方式,建议更改为 application/json 进行解析

Webhook 相关API

GET /webhooks获取店铺中所有 Webhook GET /webhooks/count获取店铺中 Webhook 总数GET /webhooks/#{id}获取指定ID的 WebhookPOST /webhooks创建新的 WebhookPUT /webhooks/#{id}修改指定ID的 WebhookDELETE /webhooks/#{id}删除指定ID的 Webhook。

GET /webhooks

获取店铺中所有 Webhook

    • limit
    • 可选,返回结果条数
      默认10,最大50
    • page
    • 可选,显示的页码
      默认1
    • since_id
    • 可选,返回大于指定ID的结果
    • topic
    • 可选,Webhook主题
    • 获取店铺中所有 Webhook 列表
    • GET /webhooks
    • {
      "webhooks": [
          {
              "address": "http://www.lavandachen.com/test/private_app_create_product_1",
              "created_at": "2015-07-09T19:55:52.106+08:00",
              "id": 6,
              "topic": "products/create",
              "updated_at": "2015-07-09T19:56:26.040+08:00",
              "content_type": "application/json"
          },
          {
              "address": "http://www.lavandachen.com/test/private_app_update_product",
              "created_at": "2015-07-09T19:56:17.382+08:00",
              "id": 7,
              "topic": "products/update",
              "updated_at": "2015-07-09T19:56:17.382+08:00",
              "content_type": "application/json"
          }
      ]
      }
      
    • 获取指定ID的 Webhook
    • GET /webhooks?ids=6,,7
    • {
      "webhooks": [
          {
              "address": "http://www.lavandachen.com/test/private_app_create_product_1",
              "created_at": "2015-07-09T19:55:52.106+08:00",
              "id": 6,
              "topic": "products/create",
              "updated_at": "2015-07-09T19:56:26.040+08:00",
              "content_type": "application/json"
          },
          {
              "address": "http://www.lavandachen.com/test/private_app_update_product",
              "created_at": "2015-07-09T19:56:17.382+08:00",
              "id": 7,
              "topic": "products/update",
              "updated_at": "2015-07-09T19:56:17.382+08:00",
              "content_type": "application/json"
          }
      ]
      }
      

GET /webhooks/count

获取店铺中 Webhook 总数

    • 获取应用创建 Webhook 总数
    • GET /webhooks/count
    • {
      "count": 2
      }
      

GET /webhooks/#{id}

获取指定ID的 Webhook

    • 获取ID为6的 Webhook
    • GET /webhooks/6
    • {
      "webhook": {
          "address": "http://www.example.com/create_product",
          "created_at": "2015-07-09T19:55:52.106+08:00",
          "id": 6,
          "topic": "products/create",
          "updated_at": "2015-07-27T14:12:12.894+08:00",
          "content_type": "application/json"
      }
      }
      

POST /webhooks

创建新的 Webhook

    • address
    • 接收通知的地址
    • topic
    • 指定事件主题
    • 创建 Webhook
    • POST /webhooks
        {
          "webhook": {
            "address": "http://www.example.com/create_product",
             "topic": "products/create",
             "content_type": "application/json"
          }
        }
      
    • {
      "webhook": {
          "address": "http://www.example.com/create_product",
          "created_at": "2015-07-09T19:55:52.106+08:00",
          "id": 6,
          "topic": "products/create",
          "updated_at": "2015-07-27T14:12:12.894+08:00",
          "content_type": "application/json"
      }
      }
      
    • 缺少topic参数,创建 Webhook 时会返回错误信息
    • POST /webhooks
        {
          "webhook": {
            "address": "http://www.example.com/create_product"
          }
        }
      
    • {
      "code": 422,
      "errors": {
          "topic": [
              "不可为空"
          ]
      }
      }
      

PUT /webhooks/#{id}

修改指定ID的 Webhook

    • address
    • 接收通知的地址
    • topic
    • 指定事件主题
    • 修改id=6对应 Webhook 的address
    • PUT /webhooks/6
        {
          "webhook": {
            "address": "http://www.example.com/create_product_1"
          }
        }
      
    • {
      "webhook": {
          "address": "http://www.example.com/create_product_1",
          "created_at": "2015-07-09T19:55:52.106+08:00",
          "id": 6,
          "topic": "products/create",
          "updated_at": "2015-07-27T14:23:59.729+08:00",
          "content_type": "application/json"
      }
      }
      

DELETE /webhooks/#{id}

删除指定ID的 Webhook。

    • 删除ID为6的 Webhook
    • DELETE /webhooks/6
    • {}
      
免费领取15天试用
立即注册
联系客服
微信咨询
微信二维码

领取免费试用资格

姓名 *

电话 *

公司名称

所在地区

意向产品

提交

提交成功

你好, XXX女士/先生 ,你的需求已提交成功,后续会有专门的客户经理与你电话联系。谢谢!