API接口调用说明
调用物联平台开放API接口的调用说明
- API的IP地址
在 云开发 -- 选择应用 -- API接口配置 -- 获取API地址 中获取
- 获取授权token
token通过oauth2.0的client credentials模式下获取的
- 获取授权token的参数说明
以下参数到 云开发 -- 应用的基础配置 中获取
字段 | 值描述 |
---|---|
client_id | 应用信息中的AccessClientId |
secret | 应用信息中的AccessSecret |
scope | 应用信息中的AccessScope |
- 获取token的请求示例:
Request Url
{api_url}/oauth/token
Request Method
POST
Request Headers
Content-Type: application/x-www-form-urlencoded
Authorization: "Authorization","Basic " + base64Encode(client_id:secret)
Request Body
grant_type=client_credentials&scope=xxx
Response Body
授权成功后,返回的数据内容
{
"access_token": "xxx", //请求API时使用的token
"token_type": "bearer", //token的类型
"expires_in": 86399, //token的有效时间(秒)
"scope": "xxx"
}
- API的请求示例:
Request Url
{api_url}/device/get
Request Method
POST
Request Headers
Content-Type: application/json; charset=UTF-8
Authorization: "bearer " + access_token
Request Body
API说明查看:开放的API接口
{
"deviceSn": "xxx"
}
Response Body
请求成功后,API返回的结果
{
"status": 0, //0:成功,非0:失败
"description": "成功", //状态描述
"payload": {} //数据内容
}