curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"url": "https://www.new-destination.com"}' \
-X PUT https://api.ayrshare.com/api/links/TkuWEy
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/links/TkuWEy", {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
url: "https://www.new-destination.com", // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'url': 'https://www.new-destination.com'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.put('https://api.ayrshare.com/api/links/TkuWEy',
json=payload,
headers=headers)
print(r.json())
require 'vendor/autoload.php';// Composer auto-loader using Guzzle. See .../guzzlephp.org/en/stable/overview.html
$client = new GuzzleHttp\Client();
$res = $client->request(
'PUT',
'https://api.ayrshare.com/api/links/TkuWEy',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'url' => 'https://www.new-destination.com',
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
{
"status": "success",
"id": "TkuWEy",
"originalUrl": "https://www.new-destination.com",
"shortUrl": "https://ayrs.io/TkuWEy",
"created": "2023-07-17T15:20:51.118Z",
"updated": "2024-01-10T12:30:00.000Z"
}
{
"action": "request",
"status": "error",
"code": 126,
"message": "Shorten URL failed. Please verify the URL is properly formatted and the correct UTM parameters are used."
}
{
"action": "link",
"status": "error",
"code": 418,
"message": "Link not found or not owned by user."
}
Links
更新短連結
更新現有短連結的目的地網址
PUT
/
links
/
:id
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"url": "https://www.new-destination.com"}' \
-X PUT https://api.ayrshare.com/api/links/TkuWEy
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/links/TkuWEy", {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
url: "https://www.new-destination.com", // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'url': 'https://www.new-destination.com'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.put('https://api.ayrshare.com/api/links/TkuWEy',
json=payload,
headers=headers)
print(r.json())
require 'vendor/autoload.php';// Composer auto-loader using Guzzle. See .../guzzlephp.org/en/stable/overview.html
$client = new GuzzleHttp\Client();
$res = $client->request(
'PUT',
'https://api.ayrshare.com/api/links/TkuWEy',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'url' => 'https://www.new-destination.com',
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
{
"status": "success",
"id": "TkuWEy",
"originalUrl": "https://www.new-destination.com",
"shortUrl": "https://ayrs.io/TkuWEy",
"created": "2023-07-17T15:20:51.118Z",
"updated": "2024-01-10T12:30:00.000Z"
}
{
"action": "request",
"status": "error",
"code": 126,
"message": "Shorten URL failed. Please verify the URL is properly formatted and the correct UTM parameters are used."
}
{
"action": "link",
"status": "error",
"code": 418,
"message": "Link not found or not owned by user."
}
更新現有短連結的目的地網址。短連結 ID 會在你首次透過
POST /links 建立短連結時回傳。
社群媒體預覽快取: 社群媒體平台會針對原始目的地網址快取 Open Graph 預覽卡片。更新短連結後,社群平台上顯示的預覽卡片在快取到期前,可能仍不會反映新的目的地。
標頭參數
路徑參數
POST /links 回傳的短連結 ID(例如 “TkuWEy”)。Body 參數
新的目的地網址。必須為有效網址,並以 https:// 開頭。
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"url": "https://www.new-destination.com"}' \
-X PUT https://api.ayrshare.com/api/links/TkuWEy
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/links/TkuWEy", {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
url: "https://www.new-destination.com", // required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'url': 'https://www.new-destination.com'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.put('https://api.ayrshare.com/api/links/TkuWEy',
json=payload,
headers=headers)
print(r.json())
require 'vendor/autoload.php';// Composer auto-loader using Guzzle. See .../guzzlephp.org/en/stable/overview.html
$client = new GuzzleHttp\Client();
$res = $client->request(
'PUT',
'https://api.ayrshare.com/api/links/TkuWEy',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'url' => 'https://www.new-destination.com',
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
{
"status": "success",
"id": "TkuWEy",
"originalUrl": "https://www.new-destination.com",
"shortUrl": "https://ayrs.io/TkuWEy",
"created": "2023-07-17T15:20:51.118Z",
"updated": "2024-01-10T12:30:00.000Z"
}
{
"action": "request",
"status": "error",
"code": 126,
"message": "Shorten URL failed. Please verify the URL is properly formatted and the correct UTM parameters are used."
}
{
"action": "link",
"status": "error",
"code": 418,
"message": "Link not found or not owned by user."
}
⌘I
