得图云应用帮助
应用API
1. OAuth2.0 API接口
1.1 请求用户授权接口
URL
http://www.detuyun.com/oauth/authorize
HTTP请求方式
GET/POST
请求参数
参数 | 必选 | 类型 | 说明 |
client_id | true | string | 申请接入时分配的appkey。 |
redirect_uri | true | string | 授权回调地址,需与设置接入的回调地址一致。 |
response_type | true | string | 返回类型(统一为字符串"code")。 |
scope | false | string | 申请权限所需参数,可一次申请多个权限,用逗号分隔。 |
state | false | string | 用于保持请求和回调的状态,在回调时,会在Query Parameter中回传该参数。开发者可以用这个参数验证请求有效性,也可以记录用户请求授权页前的位置。这个参数可用于防止跨站请求伪造(CSRF)攻击。 |
返回数据
参数 | 字段类型 | 字段说明 |
code | string | 授权后的认证参数,用于获取access_token。 |
state | string | 如果传递state参数,会回传该参数。 |
operator | string | 如果是操作员账号授权登陆,会回传该参数,该参数为操作员账号(用于记录操作员相关接口)。 |
示例
//请求
http://www.detuyun.com/oauth/authorize?client_id=100000&redirect_uri=http://hd.detuyun.com&response_type=code&state=state
//授权后重定向地址
http://hd.detuyun.com?code=CODE&state=state
1.2 获取授权过的accsss_token
URL
http://www.detuyun.com/oauth/access_token
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
client_id | true | string | 申请接入时分配的appkey。 |
client_secret | true | string | 申请接入时分配的appsecret |
redirect_uri | true | string | 回调地址,需与注册应用里的回调地址一致。 |
grant_type | true | string | 请求类型,请填写authorization_code。 |
code | true | string | 请求用户授权后获取的code值 |
返回数据
{
"access_token": "ACCESS_TOKEN",
"expires_in": 1385435451,
"scope":"SCOPE",
"uid":"12341234",
"refresh_token":"REFRESH_TOKEN"
}
返回字段 | 字段类型 | 字段说明 |
access_token | string | 授权后的access_token。 |
expires_in | int | access_token的过期时间戳。 |
scope | string | 用户授权的权限。 |
uid | string | 当前授权用户的UID。 |
refresh_token | string | access_token的刷新令牌。 |
2. 公共API
2.1 API公共参数
参数 | 必选 | 类型 | 说明 |
oauth_token | true | string | 用户授权后,通过access_token接口获取的access_token。 |
2.2 API公共错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
400 | Bad Request | oauth_token不存在 |
401 | expired_token | oauth_token已过期 |
401 | invalid_token | oauth_token不正确 |
500 | Internal Server Error | 系统内部错误 |
10001 | system error | 系统错误 |
2.3 用户接口
(1)获取用户信息
URL
http://www.detuyun.com/api/users/get_info
HTTP请求方式
GET/POST
请求参数
无需其他参数
返回数据
{
"uid": "12341234",
"email": "EMAIL",
"sex":"f",
"mobile":"MOBILE"
}
返回字段 | 字段类型 | 字段说明 |
uid | string | 用户UID。 |
email | int | 用户邮箱。 |
sex | string | 性别(f男、m女)。 |
mobile | string | 手机号码。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
20001 | user does not exists | 用户不存在 |
(2)获取用户订购本应用信息
URL
http://www.detuyun.com/api/users/get_app_info
HTTP请求方式
GET
请求参数
参数 | 必选 | 类型 | 说明 |
client_id | true | string | 申请接入时分配的appkey。 |
返回数据
{
"appname": "APPNAME",
"endtime": "2013-12-25 10:30:56",
"number":"1"
}
返回字段 | 字段类型 | 字段说明 |
appname | string | 应用名称。 |
endtime | string | 应用到期时间。 |
number | string | 订购数量。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
20002 | client_id is null | 缺少client_id参数 |
20003 | client_id is invalid | 参数client_id不合法 |
2.4 空间接口
(1)创建空间
URL
http://www.detuyun.com/api/buckets/create
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
bucket_name | true | string | 空间名称(空间名称长度为1~15位数字和小写字母组成,并且不以fw开头)。 |
bucket_type | true | int | 空间类型(0公开 1私有)。 |
pwd | false | string | 空间密码(密码为6~20位数字或者小写字母),当空间类型为私有时此参数必选。 |
返回数据
{
"bucket_name": "BUCKET_NAME",
"bucket_type": 1,
"forever_domain":"BUCKET_NAME.img.detuyun.cn",
"pwd":"PWD"
}
返回字段 | 字段类型 | 字段说明 |
bucket_name | string | 空间名称。 |
bucket_type | int | 空间类型。 |
forever_domain | string | 空间的永久域名。 |
pwd | string | 空间密码。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30001 | bucket_name is null | 缺少bucket_name参数 |
30002 | bucket_name is invalid | 空间名不符合要求 |
30003 | bucket_type is null | 缺少bucket_type参数 |
30004 | bucket_type is invalid | 空间类型不符合要求 |
30005 | pwd is null | 缺少pwd参数 |
30006 | pwd is invalid | 密码不符合要求 |
(2)获取非应用空间列表
URL
http://www.detuyun.com/api/buckets/get_list
HTTP请求方式
GET
请求参数
参数 | 必选 | 类型 | 说明 |
pageindex | false | int | 分页页码(大于等于0,分页获取时必选)。 |
pagesize | false | int | 单页个数(大于等于0,分页获取时必选)。 |
pageindex、pagesize缺少任何一个,则返回所有空间。
返回数据
[{
"bucket_name": "BUCKET_NAME",
"bucket_type": 1,
"forever_domain":"BUCKET_NAME.img.detuyun.cn",
"pwd":"PWD"
}]
返回字段 | 字段类型 | 字段说明 |
bucket_name | string | 空间名称。 |
bucket_type | int | 空间类型(0公开 1私有)。 |
forever_domain | string | 空间的永久域名。 |
pwd | string | 空间密码。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30007 | pageindex is invalid | 参数pageindex不符合要求 |
30008 | pagesize is invalid | 参数pagesize不符合要求 |
(3)获取用户对应第三方应用的空间
URL
http://www.detuyun.com/api/buckets/myapp_bucket
HTTP请求方式
GET
请求参数
参数 | 必选 | 类型 | 说明 |
client_id | true | string | 应用申请接入时分配的appkey。 |
client_secret | true | string | 应用申请接入时分配的appsecret。 |
返回数据
{
"bucket_name": "BUCKET_NAME",
"bucket_type": 1,
"forever_domain":"BUCKET_NAME.img.detuyun.cn",
"pwd":"PWD",
"isopenwhitesite":"0",
"not_found":"NOT_FOUND"
}
返回字段 | 字段类型 | 字段说明 |
bucket_name | string | 空间名称。 |
bucket_type | int | 空间类型(0公开 1私有)。 |
forever_domain | string | 空间的永久域名。 |
pwd | string | 空间密码。 |
isopenwhitesite | string | 空间是否开启白名单(0关 1开)。 |
not_found | string | 空间404图片。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30010 | client_id is null | 缺少client_id参数 |
30011 | client_secret is null | 缺少client_secret参数 |
30012 | invalid request | 请求不合法(client_id或client_secret错误) |
(4)获取空间当前存储容量
URL
http://www.detuyun.com/api/buckets/get_store
HTTP请求方式
GET
请求参数
参数 | 必选 | 类型 | 说明 |
bucket_name | true | string | 空间名称。 |
返回数据
{
"bucket_name": "BUCKET_NAME",
"usedsize": 1024
}
返回字段 | 字段类型 | 字段说明 |
bucket_name | string | 空间名称。 |
usedsize | long | 空间大小(单位B)。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30001 | bucket_name is null | 缺少bucket_name参数 |
30009 | target bucket does not exists | 空间不存在 |
(5)添加空间白名单
URL
http://www.detuyun.com/api/buckets/add_bucket_white
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
bucket_name | true | string | 空间名称。 |
domainname | true | string | 站点域名(例如:www.detuyun.com)。 |
site_name | true | string | 站点名称(长度限制20个字符)。 |
返回数据
{
"result": "ok",
"domainname": 'domainname'
}
返回字段 | 字段类型 | 字段说明 |
result | string | 返回状态(ok),表示成功。 |
domainname | string | 站点域名。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30001 | bucket_name is null | 缺少bucket_name参数 |
30009 | target bucket does not exists | 空间不存在 |
30015 | domainname is null | 缺少站点域名 |
30016 | domainname is invalid | 站点域名不符合要求 |
30017 | domainname already exists | 站点域名已经存在 |
30022 | site_name is null | 缺少站点名称 |
30025 | site_name is invalid | 站点名称不符合要求 |
(6)删除空间白名单
URL
http://www.detuyun.com/api/buckets/del_bucket_white
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
bucket_name | true | string | 空间名称。 |
domainname | true | string | 站点域名(例如:www.detuyun.com)。 |
返回数据
{
"result": "ok",
"domainname": 'domainname'
}
返回字段 | 字段类型 | 字段说明 |
result | string | 返回状态(ok),表示成功。 |
domainname | string | 站点域名。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30001 | bucket_name is null | 缺少bucket_name参数 |
30009 | target bucket does not exists | 空间不存在 |
30015 | domainname is null | 缺少站点域名 |
30019 | domainname does not exists | 站点域名不存在 |
(7)设置空间白名单状态
URL
http://www.detuyun.com/api/buckets/set_whites_status
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
bucket_name | true | string | 空间名称。 |
status | true | string | 白名单状态(0关闭 1开启)。 |
返回数据
{
"result": "ok"
}
返回字段 | 字段类型 | 字段说明 |
result | string | 返回状态(ok),表示成功。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30001 | bucket_name is null | 缺少bucket_name参数 |
30009 | target bucket does not exists | 空间不存在 |
30023 | status is null | 缺少status参数 |
30024 | status is invalid | 状态值不符合要求 |
(8)获取空间白名单列表
URL
http://www.detuyun.com/api/buckets/get_bucket_whites
HTTP请求方式
GET
请求参数
参数 | 必选 | 类型 | 说明 |
bucket_name | true | string | 空间名称。 |
返回数据
[{
"domainname": "domainname1",
“site_name”: "site_name1"
},{
"domainname": "domainname2",
“site_name”: "site_name2"
}]
返回字段 | 字段类型 | 字段说明 |
result | string | 返回状态(ok),表示成功。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30001 | bucket_name is null | 缺少bucket_name参数 |
30009 | target bucket does not exists | 空间不存在 |
(9)添加空间域名
URL
http://www.detuyun.com/api/buckets/add_bucket_domain
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
bucket_name | true | string | 空间名称。 |
domainname | true | string | 域名。 |
domain_record | true | string | 备案号(字符长度不超过50)。 |
返回数据
{
"result": "ok",
“domainname”: "domainname"
}
返回字段 | 字段类型 | 字段说明 |
result | string | 返回状态(ok),表示成功。 |
domainname | string | 域名。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30001 | bucket_name is null | 缺少bucket_name参数 |
30009 | target bucket does not exists | 空间不存在 |
30015 | domainname is null | 缺少domainname参数 |
30016 | domainname is invalid | 域名不符合要求 |
30017 | domainname already exists | 域名已存在 |
30018 | domain_record is null | 缺少domain_record参数 |
30026 | domain_record is invalid | 备案号不符合要求 |
(10)删除空间域名
URL
http://www.detuyun.com/api/buckets/del_bucket_domain
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
bucket_name | true | string | 空间名称。 |
domainname | true | string | 域名。 |
返回数据
{
"result": "ok",
“domainname”: "domainname"
}
返回字段 | 字段类型 | 字段说明 |
result | string | 返回状态(ok),表示成功。 |
domainname | string | 域名。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30001 | bucket_name is null | 缺少bucket_name参数 |
30009 | target bucket does not exists | 空间不存在 |
30015 | domainname is null | 缺少domainname参数 |
30019 | domainname does not exists | 域名不存在 |
(11)获取空间域名列表
URL
http://www.detuyun.com/api/buckets/get_bucket_domains
HTTP请求方式
GET
请求参数
参数 | 必选 | 类型 | 说明 |
bucket_name | true | string | 空间名称。 |
返回数据
[{
"domainname": "domainname",
“domain_record”: "domain_record",
"status":"0"
},{
"domainname": "domainname",
“domain_record”: "domain_record",
"status":"1"
}]
返回字段 | 字段类型 | 字段说明 |
domainname | string | 域名。 |
domain_record | string | 域名备案号。 |
status | int | 状态(-1审核不通过 0审核中 1域名解析 2未启用 3已启用)。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30001 | bucket_name is null | 缺少bucket_name参数 |
30009 | target bucket does not exists | 空间不存在 |
(12)设置空间404图片
URL
http://www.detuyun.com/api/buckets/set_bucket_404
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
bucket_name | true | string | 空间名称。 |
path | true | string | 404的图片地址(使用url编码后的浏览器访问地址)。 |
返回数据
{
"result": "ok",
“path”: "path"
}
返回字段 | 字段类型 | 字段说明 |
result | string | 返回状态(ok),表示成功。 |
path | string | 设置成功后的404图片地址。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30001 | bucket_name is null | 缺少bucket_name参数 |
30009 | target bucket does not exists | 空间不存在 |
30020 | path is null | 缺少path参数(图片URL地址) |
30021 | path is invalid | 参数path不符合要求 |
(13)获取空间404图片
URL
http://www.detuyun.com/api/buckets/set_bucket_404
HTTP请求方式
GET
请求参数
参数 | 必选 | 类型 | 说明 |
bucket_name | true | string | 空间名称。 |
返回数据
{
"bucket_name": "bucket_name",
“path”: "path"
}
返回字段 | 字段类型 | 字段说明 |
bucket_name | string | 空间名。 |
path | string | 404图片地址。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
30001 | bucket_name is null | 缺少bucket_name参数 |
30009 | target bucket does not exists | 空间不存在 |
2.5 操作员接口
(1)获取操作员信息
URL
http://www.detuyun.com/api/operators/get_operator_info
HTTP请求方式
GET
请求参数
参数 | 必选 | 类型 | 说明 |
operator | true | string | 操作员账号。 |
返回数据
{
"realname": "realname",
“operator”: "operator"
}
返回字段 | 字段类型 | 字段说明 |
operator | string | 操作员账号。 |
realname | string | 操作员姓名。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
50001 | operator is null | 缺少操作员账号参数 |
50002 | operator does not exists | 操作员不存在 |
(2)记录操作员日志
URL
http://www.detuyun.com/api/operators/write_log
HTTP请求方式
GET
请求参数
参数 | 必选 | 类型 | 说明 |
client_id | true | string | 申请接入时分配的appkey。 |
client_secret | true | string | 申请接入时分配的appsecret。 |
operator | true | string | 操作员账号。 |
message | true | string | 记录的日志信息。 |
type | true | string | 记录操作员的操作类型。 |
返回数据
{
"bucket_name": "bucket_name",
“path”: "path"
}
返回字段 | 字段类型 | 字段说明 |
bucket_name | string | 空间名。 |
path | string | 404图片地址。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
50001 | operator is null | 缺少操作员账号参数 |
50002 | operator does not exists | 操作员不存在 |
50003 | message is null | 缺少日志内容 |
50004 | type is null | 缺少操作类型 |
50005 | write log failed | 写入日志失败 |
50006 | type is invalid | 类型参数type不合法 |
50007 | client_id is null | 缺少client_id参数 |
50008 | client_secret is null | 缺少client_secret参数 |
50009 | invalid request | 第三方参数(client_id或client_secret)不正确 |
2.6 文件接口
(1)获取文件夹列表
URL
http://www.detuyun.com/api/files/get_folder_list
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
name | true | string | 空间名。 |
dir | true | string | 文件夹路径,以 / 结尾。 |
返回数据
[{
"name": "name1",
“type”: "folder",
"size": null,
"time": 1390370128,
"filetype":"DIR"
},{
"name": "name2",
“type”: "folder",
"size": null,
"time": 1390370120,
"filetype":"DIR"
}]
返回字段 | 字段类型 | 字段说明 |
name | string | 文件夹名称。 |
type | string | 固定为(folder)。 |
size | int | 值为(null)。 |
time | int | 创建此文件夹的时间戳。 |
filetype | string | 固定为(DIR)。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
40001 | bucket does not exists | 空间不存在 |
40002 | | api内部错误 |
40003 | dir is null | 缺少文件夹路径 |
40004 | name is null | 缺少空间名 |
(2)获取文件列表
URL
http://www.detuyun.com/api/files/get_file_list
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
name | true | string | 空间名。 |
dir | true | string | 文件夹路径,以 / 结尾。 |
返回数据
[{
"name": "name1",
“type”: "folder",
"size": 9692,
"time": 1390370128,
"filetype":"image/jpeg"
},{
"name": "name2",
“type”: "folder",
"size": 845941,
"time": 1390370120,
"filetype":"image/png"
}]
返回字段 | 字段类型 | 字段说明 |
name | string | 文件名称。 |
type | string | 固定为(file)。 |
size | int | 文件大小,单位为字节。 |
time | int | 上传此文件的时间戳。 |
filetype | string | 固定为(DIR)。 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
40001 | bucket does not exists | 空间不存在 |
40002 | | api内部错误 |
40003 | dir is null | 缺少文件夹路径 |
40004 | name is null | 缺少空间名 |
(3)获取文件信息
URL
http://www.detuyun.com/api/files/get_file_info
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
name | true | string | 空间名。 |
dir | true | string | 文件夹路径,以 / 结尾。 |
file_name | true | string | 文件名,包括扩展名。 |
返回数据
{
“x-detuyun-file”: "%E4%B8%AD%E5%9B%BD.jpg N 879394 1390547636"
}
返回字段 | 字段类型 | 字段说明 |
x-detuyun-file | string | url编码文件名称+N+文件大小+上传的时间戳 |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
40001 | bucket does not exists | 空间不存在 |
40002 | | api内部错误 |
40003 | dir is null | 缺少文件夹路径 |
40004 | name is null | 缺少空间名 |
40005 | file_name is null | 缺少文件名 |
(4)创建文件夹
URL
http://www.detuyun.com/api/files/make_dir
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
name | true | string | 空间名。 |
dir | true | string | 文件夹路径,以 / 结尾。 |
dir_name | true | string | 文件夹名称(目前只能由英文、数字和下划线组成)。 |
返回数据
{
“x-detuyun-file”: "OK"
}
返回字段 | 字段类型 | 字段说明 |
x-detuyun-file | string | OK(表示成功) |
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
40001 | bucket does not exists | 空间不存在 |
40002 | | api内部错误 |
40003 | dir is null | 缺少文件夹路径 |
40004 | name is null | 缺少空间名 |
40006 | dir_name is invalid | 文件夹名称不符合要求 |
(5)获取外链
URL
http://www.detuyun.com/api/files/get_file_url
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
name | true | string | 空间名。 |
dir | true | string | 文件夹路径,以 / 结尾。 |
file_name | true | string | 文件名,包括扩展名。 |
second | true | int | 外链时间长度(单位秒)。 |
返回数据
http://a.img.detuyun.cn/%E4%B8%AD%E5%9B%BD.jpg
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
40001 | bucket does not exists | 空间不存在 |
40002 | | api内部错误 |
40003 | dir is null | 缺少文件夹路径 |
40004 | name is null | 缺少空间名 |
40005 | file_name is null | 缺少文件名 |
(6)下载文件
URL
http://www.detuyun.com/api/files/down_file
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
name | true | string | 空间名。 |
dir | true | string | 文件夹路径,以 / 结尾。 |
file_name | true | string | 文件名,包括扩展名。 |
返回数据
返回文件的二进制数据
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
40001 | bucket does not exists | 空间不存在 |
40002 | | api内部错误 |
40003 | dir is null | 缺少文件夹路径 |
40004 | name is null | 缺少空间名 |
40005 | file_name is null | 缺少文件名 |
(7)上传文件
URL
http://www.detuyun.com/api/files/upload_file
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
name | true | string | 空间名。 |
dir | true | string | 文件夹路径,以 / 结尾。 |
file_name | true | string | 文件名,包括扩展名。 |
filedata | true | file | 上传的文件。 |
返回数据
“upload success”
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
40001 | bucket does not exists | 空间不存在 |
40002 | | api内部错误 |
40003 | dir is null | 缺少文件夹路径 |
40004 | name is null | 缺少空间名 |
40005 | file_name is null | 缺少文件名 |
40008 | filedata is empty | 缺少文件 |
40009 | upload failed | 上传失败 |
(9)删除文件或者文件夹
URL
http://www.detuyun.com/api/files/detele
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型 | 说明 |
name | true | string | 空间名。 |
dir | true | string | 文件夹路径,以 / 结尾。 |
file_name | false | string | 文件名,包括扩展名。 |
返回数据
“delete success”
错误信息
错误编号(code) | 错误信息(message) | 错误说明 |
40001 | bucket does not exists | 空间不存在 |
40002 | | api内部错误或者文件不存在 |
40003 | dir is null | 缺少文件夹路径 |
40004 | name is null | 缺少空间名 |