参数名 | 参数说明 | 数据类型 | 是否必填 | 默认值 |
---|---|---|---|---|
v | 接口版本号 | string | 是 | v1 |
format | 返回的数据格式 | string | 否 | json |
method | 接口的方法名 | string | 是 | null |
errorcode值为0,则表示请求成功,否则msg内容即为错误信息,data为返回的数据。
{
"errorcode": 0,
"msg": "",
"data":
}
short.url
参数名 | 参数说明 | 数据类型 | 是否必填 | 默认值 | 示例 |
---|---|---|---|---|---|
url | 需要缩短的url | string | 是 | ||
params | 需要缩短的url后跟的动态参数,举个例子,http://abc.cn/item.html?item_id=1 假设这是一个正常的商品链接,item_id是动态的,此时你有两种方式生成短链接,1你可以直接使用此链接,2使用此处的params参数,下面有实例 |
array | 是 | [] | ['item_id'] |
curl -X POST 'http://b6m.cn/api' -H 'Content-Type:application/json; charset=UTF-8' -d '{"method": "short.url", "url": "http://abc.cn/item.html?item_id=1"}'
{
"errorcode": 0,
"msg": "",
"data": {
"url": "https://blog.wanxiaohong.cn",
"short_url": "http://b6m.cn/qASOl"
}
}
curl -X POST 'http://b6m.local/api' -H 'Content-Type:application/json; charset=UTF-8' -d '{"method": "short.url", "url": "http://abc.cn/item.html", "params": ["item_id"]}'
最后的item_id
替换为你的动态ID即可,此种场景比较适合短信中需要链接,但是原始链接太长,而且各种短信平台也不允许使用动态url或者是短网址(例如阿里大鱼),此方式亲测可用
{
"errorcode": 0,
"msg": "",
"data": {
"url": "http://abc.cn/item.html",
"short_url": "http://b6m.cn/OUnpO/item_id"
}
}
Enjoy~