接口鉴权 API 密钥。 会员开通后,系统会自动为该用户生成 API 密钥。 API 密钥必须随每个请求一起发送(参见下面的完整示例)。 如果 API 密钥未发送或已过期,则会出现错误。 请确保对您的 API 密钥保密,以防止滥用。API 密钥仅向Plus级别会员开放。
要使用 API 系统进行身份验证,您需要将 API 密钥作为授权令牌与每个请求一起发送。 您可以在下面查看示例代码。右侧只是授权示例,并不是完整代码。如果您的服务器无法连接我们的接口,请联系客服添加IP白名单。
curl --location --request POST 'https://urlplus.cn/api/url/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/url/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
接口限制每 1 分钟最多 30 次请求。
您每天最多可生成1000个短网址。
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 29
X-RateLimit-Reset: TIMESTAMP
默认情况下,所有 API 响应都以 JSON 格式返回。 要将其转换为可用数据,需要根据编程语言使用适当的函数。 在 PHP 中,函数 json_decode() 可用于将数据转换为对象(默认)或数组(将第二个参数设置为 true)。
{
"error": 1,
"message": "An error ocurred"
}
https://urlplus.cn/api/account
查询当前帐号信息。
curl --location --request GET 'https://urlplus.cn/api/account' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/account",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"error": 0,
"data": {
"id": 1,
"email": "sample@domain.com",
"username": "sampleuser",
"avatar": "https:\/\/domain.com\/content\/avatar.png",
"status": "pro",
"expires": "2022-11-15 15:00:00",
"registered": "2020-11-10 18:01:43"
}
}
https://urlplus.cn/api/account/update
要更新帐户信息,您可以向此接口发送请求,它将更新帐户数据。
curl --location --request PUT 'https://urlplus.cn/api/account/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "newemail@google.com",
"password": "newpassword"
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/account/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
CURLOPT_POSTFIELDS => '{
"email": "newemail@google.com",
"password": "newpassword"
}',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"error": 0,
"message": "Account has been successfully updated."
}
https://urlplus.cn/api/urls?limit=2&page=1&order=date
要通过 API 获取链接,您可以使用此接口。 您还可以过滤数据(请参阅表格了解更多信息)。
参数 | 描述 |
---|---|
limit | (可选) 每页数量 |
page | (可选) 页码 |
order | (可选) 排序方式[date | click] |
curl --location --request GET 'https://urlplus.cn/api/urls?limit=2&page=1&order=date' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/urls?limit=2&page=1&order=date",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"error": "0",
"data": {
"result": 2,
"perpage": 2,
"currentpage": 1,
"nextpage": 1,
"maxpage": 1,
"urls": [
{
"id": 2,
"alias": "google",
"shorturl": "https:\/\/urlplus.cn\/google",
"longurl": "https:\/\/google.com",
"clicks": 0,
"title": "Google",
"description": "",
"date": "2020-11-10 18:01:43"
},
{
"id": 1,
"alias": "googlecanada",
"shorturl": "https:\/\/urlplus.cn\/googlecanada",
"longurl": "https:\/\/google.ca",
"clicks": 0,
"title": "Google Canada",
"description": "",
"date": "2020-11-10 18:00:25"
}
]
}
}
https://urlplus.cn/api/url/:id
要通过 API 获取单个链接的详细信息,您可以使用此接口。
curl --location --request GET 'https://urlplus.cn/api/url/:id' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/url/:id",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"error": 0,
"details": {
"id": 1,
"shorturl": "https:\/\/urlplus.cn\/googlecanada",
"longurl": "https:\/\/google.com",
"title": "Google",
"description": "",
"location": {
"canada": "https:\/\/google.ca",
"united states": "https:\/\/google.us"
},
"device": {
"iphone": "https:\/\/google.com",
"android": "https:\/\/google.com"
},
"expiry": null,
"date": "2020-11-10 18:01:43"
},
"data": {
"clicks": 0,
"uniqueClicks": 0,
"topCountries": 0,
"topReferrers": 0,
"topBrowsers": 0,
"topOs": 0,
"socialCount": {
"facebook": 0,
"twitter": 0,
"google": 0
}
}
}
https://urlplus.cn/api/url/add
要生成短网址,您需要通过 POST 请求以 JSON 格式发送有效数据。 数据必须作为请求的原始主体发送,如下所示。 下面的示例显示了您可以发送的所有参数,但您不需要发送所有参数(有关更多信息,请参见表格)
参数 | 描述 |
---|---|
url | (必选) 需要缩短的长链接。 |
custom | (可选) 自定义短网址. |
type | (可选) 跳转方式 [direct, splash] |
password | (可选) 访问密码 |
domain | (可选) 短网址域名,如https://tb8.eu |
expiry | (可选) 过期时间,如2023-09-28 23:11:16 |
geotarget | (可选) 地区定向 |
devicetarget | (可选) 设备定向 |
curl --location --request POST 'https://urlplus.cn/api/url/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https:\/\/google.com",
"custom": "google",
"password": "mypass",
"expiry": "2020-11-11 12:00:00",
"type": "splash",
"geotarget": [
{
"location": "Canada",
"link": "https:\/\/google.ca"
},
{
"location": "United States",
"link": "https:\/\/google.us"
}
],
"devicetarget": [
{
"device": "iPhone",
"link": "https:\/\/google.com"
},
{
"device": "Android",
"link": "https:\/\/google.com"
}
],
"parameters": [
{
"name": "aff",
"value": "3"
},
{
"device": "gtm_source",
"link": "api"
}
]
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/url/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
CURLOPT_POSTFIELDS => '{
"url": "https:\/\/google.com",
"custom": "google",
"password": "mypass",
"expiry": "2020-11-11 12:00:00",
"type": "splash",
"geotarget": [
{
"location": "Canada",
"link": "https:\/\/google.ca"
},
{
"location": "United States",
"link": "https:\/\/google.us"
}
],
"devicetarget": [
{
"device": "iPhone",
"link": "https:\/\/google.com"
},
{
"device": "Android",
"link": "https:\/\/google.com"
}
],
"parameters": [
{
"name": "aff",
"value": "3"
},
{
"device": "gtm_source",
"link": "api"
}
]
}',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"error": 0,
"id": 3,
"short": "https:\/\/urlplus.cn\/google"
}
https://urlplus.cn/api/url/:id/update
要更新短网址,您需要通过 PUT 请求以 JSON 格式发送有效数据。 数据必须作为请求的原始主体发送,如下所示。 下面的示例显示了您可以发送的所有参数,但您不需要发送所有参数(有关更多信息,请参见表格)。
参数 | 描述 |
---|---|
url | (必选) 需要缩短的长链接。 |
custom | (可选) 自定义短网址. |
type | (可选) 跳转方式 [direct, splash] |
password | (可选) 访问密码 |
expiry | (可选) 过期时间,如2023-09-28 23:11:16 |
geotarget | (可选) 地区定向 |
devicetarget | (可选) 设备定向 |
curl --location --request PUT 'https://urlplus.cn/api/url/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "https:\/\/google.com",
"custom": "google",
"password": "mypass",
"expiry": "2020-11-11 12:00:00",
"type": "splash",
"geotarget": [
{
"location": "Canada",
"link": "https:\/\/google.ca"
},
{
"location": "United States",
"link": "https:\/\/google.us"
}
],
"devicetarget": [
{
"device": "iPhone",
"link": "https:\/\/google.com"
},
{
"device": "Android",
"link": "https:\/\/google.com"
}
],
"parameters": [
{
"name": "aff",
"value": "3"
},
{
"device": "gtm_source",
"link": "api"
}
]
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/url/:id/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
CURLOPT_POSTFIELDS => '{
"url": "https:\/\/google.com",
"custom": "google",
"password": "mypass",
"expiry": "2020-11-11 12:00:00",
"type": "splash",
"geotarget": [
{
"location": "Canada",
"link": "https:\/\/google.ca"
},
{
"location": "United States",
"link": "https:\/\/google.us"
}
],
"devicetarget": [
{
"device": "iPhone",
"link": "https:\/\/google.com"
},
{
"device": "Android",
"link": "https:\/\/google.com"
}
],
"parameters": [
{
"name": "aff",
"value": "3"
},
{
"device": "gtm_source",
"link": "api"
}
]
}',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"error": 0,
"id": 3,
"short": "https:\/\/urlplus.cn\/google"
}
https://urlplus.cn/api/url/:id/delete
要删除链接,您需要发送 DELETE 请求。
curl --location --request DELETE 'https://urlplus.cn/api/url/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/url/:id/delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"error": 0,
"message": "Link has been deleted successfully"
}
https://urlplus.cn/api/qr?limit=2&page=1
要通过 API 获取二维码,您可以使用此端点。 您还可以过滤数据(有关更多信息,请参见表格)。
参数 | 描述 |
---|---|
limit | (可选) 每页条数 |
page | (可选) 页码 |
curl --location --request GET 'https://urlplus.cn/api/qr?limit=2&page=1' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/qr?limit=2&page=1",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"error": "0",
"data": {
"result": 2,
"perpage": 2,
"currentpage": 1,
"nextpage": 1,
"maxpage": 1,
"qrs": [
{
"id": 2,
"link": "https:\/\/urlplus.cn\/qr\/a2d5e",
"scans": 0,
"title": "Google",
"date": "2020-11-10 18:01:43"
},
{
"id": 1,
"link": "https:\/\/urlplus.cn\/qr\/b9edfe",
"scans": 5,
"title": "Google Canada",
"date": "2020-11-10 18:00:25"
}
]
}
}
https://urlplus.cn/api/qr/:id
要通过 API 获取单个二维码的详细信息,您可以使用此端点。
curl --location --request GET 'https://urlplus.cn/api/qr/:id' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/qr/:id",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"error": 0,
"details": {
"id": 1,
"link": "https:\/\/urlplus.cn\/qr\/b9edfe",
"scans": 5,
"title": "Google Canada",
"date": "2020-11-10 18:00:25"
},
"data": {
"clicks": 1,
"uniqueClicks": 1,
"topCountries": {
"Unknown": "1"
},
"topReferrers": {
"Direct, email and other": "1"
},
"topBrowsers": {
"Chrome": "1"
},
"topOs": {
"Windows 10": "1"
},
"socialCount": {
"facebook": 0,
"twitter": 0,
"instagram": 0
}
}
}
https://urlplus.cn/api/qr/add
要缩短 QR 码,您需要通过 POST 请求以 JSON 格式发送有效数据。 数据必须作为请求的原始主体发送,如下所示。 下面的示例显示了您可以发送的所有参数,但您不需要发送所有参数(有关更多信息,请参见表格)。
参数 | 描述 |
---|---|
type | (必选)二维码类型: text | vcard | link | email | phone | sms | wifi |
data | (必选) 包含的数据,可以是字符串或数组 |
background | (可选) 背景色。如 #ffffff |
foreground | (可选) 前景色。如 #000000 |
logo | (可选) logo地址,支持png和jpg格式 |
curl --location --request POST 'https://urlplus.cn/api/qr/add' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"type": "link",
"data": "https:\/\/google.com",
"background": "#ffffff",
"foreground": "#000000",
"logo": "https:\/\/site.com\/logo.png"
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/qr/add",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
CURLOPT_POSTFIELDS => '{
"type": "link",
"data": "https:\/\/google.com",
"background": "#ffffff",
"foreground": "#000000",
"logo": "https:\/\/site.com\/logo.png"
}',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"error": 0,
"id": 3,
"link": "https:\/\/urlplus.cn\/qr\/a58f79"
}
https://urlplus.cn/api/qr/:id/update
要更新二维码,您需要通过 PUT 请求以 JSON 格式发送有效数据。 数据必须作为请求的原始主体发送,如下所示。 下面的示例显示了您可以发送的所有参数,但您不需要发送所有参数(有关更多信息,请参见表格)。
参数 | 描述 |
---|---|
data | (必选) 包含的数据,可以是字符串或数组 |
background | (可选) 背景色。如 #ffffff |
foreground | (可选) 前景色。如 #000000 |
logo | (可选) logo地址,支持png和jpg格式 |
curl --location --request PUT 'https://urlplus.cn/api/qr/:id/update' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"type": "link",
"data": "https:\/\/google.com",
"background": "#ffffff",
"foreground": "#000000",
"logo": "https:\/\/site.com\/logo.png"
}'
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/qr/:id/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
CURLOPT_POSTFIELDS => '{
"type": "link",
"data": "https:\/\/google.com",
"background": "#ffffff",
"foreground": "#000000",
"logo": "https:\/\/site.com\/logo.png"
}',
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"error": 0,
"message": "QR has been updated successfully."
}
https://urlplus.cn/api/qr/:id/delete
要删除二维码,您需要发送 DELETE 请求。
curl --location --request DELETE 'https://urlplus.cn/api/qr/:id/delete' \
--header 'Authorization: Bearer YOURAPIKEY' \
--header 'Content-Type: application/json' \
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://urlplus.cn/api/qr/:id/delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 2,
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer YOURAPIKEY",
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
{
"error": 0,
"message": "QR Code has been deleted successfully."
}