接口地址: http://api.70api.com/api/dygit/

支持协议: HTTP/HTTPS

返回格式: JSON

请求方式: GET

请求示例: http://api.70api.com/api/dygit/?apiKey=e8046d6019bcd6face4fbcb3dda40c3e&url=http://baidu.com

请求参数说明:

名称 必填 类型 说明
apiKey string 登录平台购买对应API产品获得唯一标识 : apiKey
url string 需要缩短的网址 如果url带参数请进行urlencode

返回参数说明:

名称 类型 说明
res boolean 返回结果 true|false
data array 返回的结果
msg string 提示信息
code int 0为正常 其他为异常

返回示例:

{
	"res": true,
	"code": 0,
	"msg": "成功",
	"data": {
		"short_url": "https://git.io/336C9b",
		"long_url": "https://www.baidu.com"
	},
	"timestamp": 1584964472
}

参数名称 参数值


{
	"res": true,
	"code": 0,
	"msg": "成功",
	"data": {
		"short_url": "https://git.io/336C9b",
		"long_url": "https://www.baidu.com"
	},
	"timestamp": 1584964472
}

错误码格式说明:

名称 类型 说明
40001 string 请求频繁,请稍后再试!
40004 string 非法请求
10009 string 该api暂时停止服务
10001 string 参数错误,请参考文档传递正确参数
10000 string 缺少必填参数,请参考文档传递必填参数

代码示例:

$api = 'http://api.70api.com/api/dygit/?apiKey=e8046d6019bcd6face4fbcb3dda40c3e&url=http://baidu.com';

$result = json_decode(file_get_contents($api), 1);

if (!empty($result['data']) && !empty($result['data']['short_url'])) {
echo '获取成功: ' . $result['data']['short_url'];
} else {
echo '获取失败:' . (empty($result['msg']) ? '未知错误' : $result['msg']);
}