API:ShortURL - 短網(wǎng)址
概覽
Shorturl是 SUBMAIL 的短網(wǎng)址 API。
使用 Shorturl API 可以獲取、創(chuàng)建、編輯或刪除您的短網(wǎng)址。
shorturl API 使用 HTTP 規(guī)范中的 GET, POST, PUT, DELETE 方法對短網(wǎng)址進行操作,使用 GET 方法獲取單個或全部短網(wǎng)址、POST 方法創(chuàng)建新的短網(wǎng)址并提交至 SUBMAIL 人工審核、PUT 方法更新或編輯一個短網(wǎng)址,或使用 DELETE 方法刪除一個短網(wǎng)址。
短網(wǎng)址引擎支持 SUBHOOK 異步推送狀態(tài),短網(wǎng)址在后臺人工審核后,會使用 SUBHOOK 進行主動推送狀態(tài)。
URL
<主> https://service.mysubmail.com/shorturl
支持格式
| 格式 | URL |
|---|---|
json | https://service.mysubmail.com/shorturl.json(默認) |
xml | https://service.mysubmail.com/shorturl.xml |
http 請求方式
| GET | 獲取全部短網(wǎng)址,或獲取指定的單個短網(wǎng)址 |
|---|---|
| POST | 創(chuàng)建一個新的短網(wǎng)址 |
| PUT | 編輯或更新一個短網(wǎng)址 |
| DELETE | 刪除一個短網(wǎng)址 |
是否需要授權
是
參閱 API 授權和驗證機制
ShortURl GET 方法(獲取短網(wǎng)址列表)請求參數(shù)
| 參數(shù) | 類型 | 必需/可選 | 默認 | 描述 |
|---|---|---|---|---|
appid | string | 必需 | 無 | 在 SUBMAIL 應用集成中創(chuàng)建的短網(wǎng)址應用ID |
short_url | string | 必需 | 無 | 短網(wǎng)址 要獲取單個模板,請將在此參數(shù)中提交您要查詢的具體短網(wǎng)址。為空則獲取所有的短網(wǎng)址。 |
rows | int | 可選 | 100 | 單次返回數(shù)據(jù)的行數(shù) 請將該值控制在10-1000之間,若指定了一個無效的 rows 參數(shù),API 將默認返回 100行數(shù)據(jù) |
offset | int | 可選 | 0 | 數(shù)據(jù)偏移指針 該值可以指定返回數(shù)據(jù)的偏移指針,例:假如單次請求包含150條數(shù)據(jù),rows參數(shù)采用50行,此時需要查詢第51-100行的數(shù)據(jù),請將 offset 參數(shù)設為1(即數(shù)據(jù)偏移50行)即可得到第51-100行的數(shù)據(jù),offset=2時,將返回第101-150行數(shù)據(jù),以此類推 |
group | string | 可選 | 無 | 短網(wǎng)址群組ID |
timestamp | UNIX 時間戳 | 可選 | 無 | 參閱 API 授權與驗證機制 > Timestamp UNIX 時間戳 |
sign_type | string | 可選 | normal | API 授權模式( md5 or sha1 or normal )參閱 API 授權與驗證機制 > 授權和驗證方式 |
signature | string | 必需 | 無 | 應用密匙 或 數(shù)字簽名 參閱 API 授權與驗證機制 > 授權和驗證方式 |
ShortURl POST 方法(創(chuàng)建短網(wǎng)址)請求參數(shù)
| 參數(shù) | 類型 | 必需/可選 | 默認 | 描述 |
|---|---|---|---|---|
appid | string | 必需 | 無 | 在 SUBMAIL 應用集成中創(chuàng)建的短網(wǎng)址應用ID |
model | string | 可選 | url | 設置 URL 訪問模式 *設置 URL 參數(shù)為 url-scheme 為 App 內鏈模式(或微信小程序); 設置參數(shù)為 mp-wechat 為微信公眾號模式,需授權 SUBMAIL 小程序 ,smpp-wechat為微信小程序模式 (請謹慎使用此模式) |
sapp_id | string | 條件可選 | 無 | 小程序id,model=sapp-wechat時必填 |
sapp_key | string | 條件可選 | 無 | 小程序key, model=sapp-wechat時必填 |
url | string | 必需 | 無 | 默認目標網(wǎng)址。 您需要處理成短網(wǎng)址的長網(wǎng)址。 |
group | string | 可選 | 無 | 短網(wǎng)址群組ID |
item | string | 可選 | 無 | 自定義標記。 手機號碼,國際手機號碼,郵件地址,或任意字符串,此參數(shù)通常配合 短網(wǎng)址群組功能使用。(最大長度不能超過32位) |
domain | string | 可選 | link.wiki | 域名選擇。 SUBMAIL提供的域名選擇:link.wiki、suburl.cn、s1k.cn、3s6.cn 企業(yè)版支持自定義域名設置。 |
access_password | string | 可選 | 無 | 訪問密碼。 |
access_limit | int | 可選 | 無 | 訪問次數(shù)限制。 |
expire | int | 可選 | 無 | 設置短鏈接過期時間,按小時計算,默認過期時間為當前套餐的最大時長。 |
routes | jsonString | 可選 | 無 | 短網(wǎng)址路由。 此參數(shù)支持對桌面端,移動端,app,機器人的路由跳轉操作 具體參數(shù)示列請參考ShortUrl Routes參數(shù)說明 |
tag | string | 可選 | 無 | 此參數(shù)用于標記一次 API 請求(最大長度不超過 64 位) 添加了 tag 參數(shù)的 API 請求,會在所有的 SUBHOOK 事件中攜帶此參數(shù)。 |
timestamp | UNIX 時間戳 | 可選 | 無 | 參閱 API 授權與驗證機制 > Timestamp UNIX 時間戳 |
sign_type | string | 可選 | normal | API 授權模式( md5 or sha1 or normal )參閱 API 授權與驗證機制 > 授權和驗證方式 |
signature | string | 必需 | 無 | 應用密匙 或 數(shù)字簽名 參閱 API 授權與驗證機制 > 授權和驗證方式 |
ShortURl PUT 方法(更新短鏈接)請求參數(shù)
| 參數(shù) | 類型 | 必需/可選 | 默認 | 描述 |
|---|---|---|---|---|
appid | string | 必需 | 無 | 在 SUBMAIL 應用集成中創(chuàng)建的短網(wǎng)址的應用 ID |
model | string | 可選 | url | 設置 URL 訪問模式 *設置 URL 參數(shù)為 url-scheme 為 App 內鏈模式(或微信小程序); 設置參數(shù)為 mp-wechat 為微信公眾號模式,需授權 SUBMAIL 小程序 ,smpp-wechat為微信小程序模式 (請謹慎使用此模式) |
sapp_id | string | 條件可選 | 無 | 小程序id,model=sapp-wechat時必填 |
sapp_key | string | 條件可選 | 無 | 小程序key, model=sapp-wechat時必填 |
short_url | string | 必需 | 無 | 目標短網(wǎng)址 |
url | string | 可選 | 無 | 目標網(wǎng)址 |
pause | string | 可選 | 無 | 短網(wǎng)址模板是否暫停使用。 參數(shù)為true或者false |
item | string | 可選 | 無 | 自定義標記。 手機號碼,國際手機號碼,郵件地址,或任意字符串,此參數(shù)通常配合 短網(wǎng)址群組功能使用。(最大長度不能超過32位) |
access_password | string | 可選 | 無 | 訪問密碼 |
access_limit | int | 可選 | 無 | 訪問次數(shù)限制 |
expire | int | 可選 | 無 | 設置短網(wǎng)址過期時間,按小時計算,默認過期時間為當前套餐的最大時長。 |
tag | string | 可選 | 無 | 此參數(shù)用于標記一次 API 請求(最大長度不超過 32 位) 添加了 tag 參數(shù)的 API 請求,會在所有的 SUBHOOK 事件中攜帶此參數(shù)。 |
timestamp | UNIX 時間戳 | 可選 | 無 | 參閱 API 授權與驗證機制 > Timestamp UNIX 時間戳 |
sign_type | string | 可選 | normal | API 授權模式( md5 or sha1 or normal )參閱 API 授權與驗證機制 > 授權和驗證方式 |
signature | string | 必需 | 無 | 應用密匙 或 數(shù)字簽名 參閱 API 授權與驗證機制 > 授權和驗證方式 |
ShortURL DELETE 方法(刪除短網(wǎng)址)請求參數(shù)
| 參數(shù) | 類型 | 必需/可選 | 默認 | 描述 |
|---|---|---|---|---|
appid | string | 必需 | 無 | 在 SUBMAIL 應用集成中創(chuàng)建的短網(wǎng)址應用 ID |
short_url | string | 必需 | 無 | 需要刪除的目標短網(wǎng)址 |
timestamp | UNIX 時間戳 | 可選 | 無 | 參閱 API 授權與驗證機制 > Timestamp UNIX 時間戳 |
sign_type | string | 可選 | normal | API 授權模式( md5 or sha1 or normal )參閱 API 授權與驗證機制 > 授權和驗證方式 |
signature | string | 必需 | 無 | 應用密匙 或 數(shù)字簽名 參閱 API 授權與驗證機制 > 授權和驗證方式 |
ShortURL Routes參數(shù)說明
routes參數(shù)json結構說明
routes
desktop :可選參數(shù)。設置桌面端操作系統(tǒng)點擊跳轉的目標url,如果此參數(shù)不傳則跳轉到默認設置目標url。
windows :可選參數(shù)。設置windows操作系統(tǒng)點擊跳轉的目標url,如果此參數(shù)不傳則跳轉到默認設置目標url。
mac :可選參數(shù)。設置mac操作系統(tǒng)點擊跳轉的目標url,如果此參數(shù)不傳則跳轉到默認設置目標url。
linux :可選參數(shù)。設置linux操作系統(tǒng)點擊跳轉目標url,如果此參數(shù)不傳則跳轉到默認設置目標url。
mobile:可選參數(shù)。設置移動端操作系統(tǒng)點擊跳轉目標url,如果此參數(shù)不傳則跳轉到默認設置目標url。
device:可選參數(shù)。如果此參數(shù)不傳則跳轉到默認設置目標url。
ios:可選參數(shù)。設置ios操作系統(tǒng)點擊跳轉目標url,如果此參數(shù)不傳則跳轉到默認設置目標url。
android:可選參數(shù)。設置android操作系統(tǒng)點擊跳轉目標url,如果此參數(shù)不傳則跳轉到默認設置目標url。
others:可選參數(shù)。設置除ios,android操作系統(tǒng)外點擊跳轉目標url,如果此參數(shù)不傳則跳轉到默認設置目標url。
app:可選參數(shù)。設置微信以及支付寶點擊跳轉目標url,如果此參數(shù)不傳則跳轉到對應手機操作系統(tǒng)設置的目標跳轉url。
wechat:可選參數(shù)。設置微信app內點擊跳轉目標url,如果此參數(shù)不傳則跳轉到對應手機操作系統(tǒng)設置的目標跳轉url。
alipay:可選參數(shù)。設置支付寶app內點擊跳轉目標url,如果此參數(shù)不傳則跳轉到對應手機操作系統(tǒng)設置的目標跳轉url。
robot:可選參數(shù)。設置機器人點擊跳轉目標地址,如果此參數(shù)不傳則跳轉到默認設置目標url。
routes參數(shù)json字符串示列
{
"desktop": {
"windows": {"url":"http://www.reatop.cn/windows","model":"url"},
"mac": {"url":"http://www.reatop.cn/mac","model":"url"},
"linux": {"url":"http://www.reatop.cn/linux","model":"url"},
"other": {"url":"http://www.reatop.cn/other","model":"url"}
},
"mobile": {
"device": {
"ios": {"url":"weixin://dl/business/?ticket=***","model":"url-scheme"},
"android": {"url":"http://www.reatop.cn/android","model":"url"},
"others": {"url":"http://www.reatop.cn/others","model":"url"}
},
"app": {
"wechat":{"url":"http://www.reatop.cn/wechat","model":"url"},
"alipay": {"url":"http://www.reatop.cn/alipay","model":"url"},
"others": {"url":"http://www.reatop.cn/others","model":"url"}
}
},
"robot": {"url":"http://www.reatop.cn/robot","model":"url"}
}代碼示例
使用 CURL GET方法獲取模板列表
發(fā)送 CURL
curl -s "https://service.mysubmail.com/shorturl?appid=your_appid&signature=your_appkey"返回
{
"status": "success",
"urls": [
{
"short_url": "http://link.wiki/anPi5G",
"long_url": "http://mysubmail.cn/developer",
"items": "",
"access_password": "0",
"access_limit": "0",
"pause": "false",
"routes": {
"desktop": {
"windows": {"url":"http://www.reatop.cn/windows","model":"url"},
"mac": {"url":"http://www.reatop.cn/mac","model":"url"},
"linux": {"url":"http://www.reatop.cn/linux","model":"url"},
"other": {"url":"http://www.reatop.cn/other","model":"url"}
},
"mobile": {
"device": {
"ios": {"url":"weixin://dl/business/?ticket=***","model":"url-scheme"},
"android": {"url":"http://www.reatop.cn/android","model":"url"},
"others": {"url":"http://www.reatop.cn/others","model":"url"}
},
"app": {
"wechat":{"url":"http://www.reatop.cn/wechat","model":"url"},
"alipay": {"url":"http://www.reatop.cn/alipay","model":"url"},
"others": {"url":"http://www.reatop.cn/others","model":"url"}
}
},
"robot": {"url":"http://www.reatop.cn/robot","model":"url"}
},
"qrcode": "http://suburl.cn/qrcode?url=httxxxink.wiki/KSWfb5",
"tag": "test2",
"create_at": "2019-07-17 10:28:11",
"review_status": "2",
"review_status_description": "通過審核",
"expire_by_hours": "168",
"expire_at": "2019-07-24 10:28:11"
},
{
"short_url": "http://sw2.co/bTOCOG",
"long_url": "http://www.baidu.com",
"items": "",
"access_password": "0",
"access_limit": "0",
"pause": "false",
"routes": {
"desktop": {
"windows": "http://www.reatop.cn/windows",
"mac": "http://www.reatop.cn/mac",
"linux": "http://www.reatop.cn/linux"
},
"mobile": {
"device": {
"ios": "http://www.reatop.cn/ios",
"android": "http://www.reatop.cn/android",
"others": "http://www.reatop.cn/others"
},
"app": {
"wechat": "http://www.reatop.cn/chs/store",
"alipay": "http://www.reatop.cn/slinks"
}
},
"robot": "http://www.reatop.cn/robot"
},
"qrcode": "http://suburl.cn/qrcode?url=httxxxink.wiki/KSWfb5",
"tag": "",
"create_at": "2019-07-17 09:57:47",
"review_status": "2",
"review_status_description": "通過審核",
"expire_by_hours": "168",
"expire_at": "2019-07-24 09:57:47"
}
]
}使用 CURL POST方法提交短網(wǎng)址
發(fā)送 CURL
curl -d "appid=your_appid&signature=your_appkey&url=https://www.api.submail.cn&group=09ae645ddd5200915&item=test&routes={"desktop":{"windows":"http://www.reatop.cn/windows","mac":"http://www.reatop.cn/mac","linux":"http://www.reatop.cn/linux"},"mobile":{"device":{"ios":"http://www.reatop.cn/ios","android":"http://www.reatop.cn/android","others":"http://www.reatop.cn/others"},"app":{"wechat":"http://www.reatop.cn/wechat","alipay":"http://www.reatop.cn/alipay"}},"robot":"http://www.reatop.cn/robot"}"。" https://service.mysubmail.com/shorturl.json返回
{
"status": "success",
"short_url": "http://link.wiki/KSWfb5",
"long_url": "https://blog.csdn.net/fdipzone/article/details/42463727/32132131、321///23123/32132133213",
"routes": {
"desktop": {
"windows": {"url":"http://www.reatop.cn/windows","model":"url"},
"mac": {"url":"http://www.reatop.cn/mac","model":"url"},
"linux": {"url":"http://www.reatop.cn/linux","model":"url"},
"other": {"url":"http://www.reatop.cn/other","model":"url"}
},
"mobile": {
"device": {
"ios": {"url":"weixin://dl/business/?ticket=***","model":"url-scheme"},
"android": {"url":"http://www.reatop.cn/android","model":"url"},
"others": {"url":"http://www.reatop.cn/others","model":"url"}
},
"app": {
"wechat":{"url":"http://www.reatop.cn/wechat","model":"url"},
"alipay": {"url":"http://www.reatop.cn/alipay","model":"url"},
"others": {"url":"http://www.reatop.cn/others","model":"url"}
}
},
"robot": {"url":"http://www.reatop.cn/robot","model":"url"}
},
"qrcode": "http://suburl.cn/qrcode?url=httxxxink.wiki/KSWfb5",
"expire_at": "2021-04-01 16:33:42"
}qrcode:為目標短網(wǎng)址生成的二維碼地址。
使用 CURL PUT 方法修改短網(wǎng)址
發(fā)送 CURL
curl --data "appid=your_appid&signature=your_appkey&short_url=http://link.wiki/iM/GuvPeD&url=http://www.reatop.cn&pause=true&item=submail&expire=100" -X put https://service.mysubmail.com/shorturl.json返回
{
"status":"success"
}使用 CURL DELETE 方法刪除短網(wǎng)址
發(fā)送 CURL
curl --data "appid=your_appid&signature=your_appkey&short_url=http://link.wiki/iM/GuvPeD" -X delete https://service.mysubmail.com/shorturl.json返回
{
"status":"success"
}review_status 短網(wǎng)址狀態(tài)描述
review_status : 0 | 未提交審核 |
|---|---|
review_status : 1 | 正在審核 |
review_status : 2 | 審核通過 |
review_status : 3 | 未通過審核 |
返回值
請求成功
{
"status":"success"
}請求失敗
{
"status":"error",
"code":"1xx",
"msg":"error message"
}