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

支持协议: HTTP/HTTPS

返回格式: JSON

请求方式: GET

请求示例: http://api.70api.com/api/urlcn/?apiKey=6d554e1c14101ed557cc0be1a2e3f657&url=http://baidu.com

请求参数说明:

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

返回参数说明:

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

返回示例:

{
	"res": true,
	"code": 0,
	"msg": "成功",
	"data": {
		"short_url": "http://sc.qq.com/fx/u?r=LGuTht#?t=7Dycj",
		"long_url": "https://www.baidu.com"
	},
	"timestamp": 1584964472
}

参数名称 参数值


{
	"res": true,
	"code": 0,
	"msg": "成功",
	"data": {
		"short_url": "http://sc.qq.com/fx/u?r=LGuTht#?t=7Dycj",
		"long_url": "https://www.baidu.com"
	},
	"timestamp": 1584964472
}

错误码格式说明:

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

代码示例:

$api = 'http://api.70api.com/api/urlcn/?apiKey=6d554e1c14101ed557cc0be1a2e3f657&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']);
}