取得 Instagram 音訊中繼資料
curl --request GET \
--url https://api.ayrshare.com/api/media/instagram/audio/{audioId} \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.ayrshare.com/api/media/instagram/audio/{audioId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.ayrshare.com/api/media/instagram/audio/{audioId}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/media/instagram/audio/{audioId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.ayrshare.com/api/media/instagram/audio/{audioId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.ayrshare.com/api/media/instagram/audio/{audioId}")
.header("Authorization", "Bearer <token>")
.asString();{
"status": "success",
"audioId": "17901234567890123",
"title": "Summer Nights",
"displayArtist": "The Example Band",
"durationMs": 32000,
"thumbnailUrl": "https://scontent.example.com/cover.jpg",
"audioType": "music",
"isAdsEligible": true
}
{
"status": "error",
"code": 517,
"action": "post",
"message": "The selected audio track is unavailable. It may be an invalid audio id, restricted in your region, or not licensed for this use. Please choose a different track using the Instagram audio search endpoint and try again.",
"platform": "instagram"
}
Media
取得 Instagram 音訊中繼資料
以 id 查詢單一 Instagram 音訊曲目的詳細資料
GET
/
media
/
instagram
/
audio
/
{audioId}
取得 Instagram 音訊中繼資料
curl --request GET \
--url https://api.ayrshare.com/api/media/instagram/audio/{audioId} \
--header 'Authorization: Bearer <token>'const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.ayrshare.com/api/media/instagram/audio/{audioId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.ayrshare.com/api/media/instagram/audio/{audioId}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ayrshare.com/api/media/instagram/audio/{audioId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.ayrshare.com/api/media/instagram/audio/{audioId}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.ayrshare.com/api/media/instagram/audio/{audioId}")
.header("Authorization", "Bearer <token>")
.asString();{
"status": "success",
"audioId": "17901234567890123",
"title": "Summer Nights",
"displayArtist": "The Example Band",
"durationMs": 32000,
"thumbnailUrl": "https://scontent.example.com/cover.jpg",
"audioType": "music",
"isAdsEligible": true
}
{
"status": "error",
"code": 517,
"action": "post",
"message": "The selected audio track is unavailable. It may be an invalid audio id, restricted in your region, or not licensed for this use. Please choose a different track using the Instagram audio search endpoint and try again.",
"platform": "instagram"
}
以
錯誤碼 514 到 518 的說明請參閱 Instagram Reels 音訊錯誤;其餘錯誤碼請參閱 Ayrshare 錯誤參考。
audioId 擷取單一音訊曲目的詳細資料。可用來確認先前儲存的 id 是否仍然有效,或在發布前顯示曲目的標題與封面圖。
標頭參數
路徑參數
回應欄位
曲目的欄位會以扁平方式直接回傳在回應物件上,而非巢狀結構。Instagram 不會為每首曲目回傳所有欄位,因此除audioId 以外的所有欄位都應視為選填。
string
找到曲目時為
success。string
曲目 id,原樣回傳。
string
曲目標題。
string
Instagram 所顯示的藝人名稱。
integer
曲目長度(毫秒)。
string
封面圖縮圖 URL。
string
music 或 original_sound。boolean
該曲目是否可用於廣告。
{
"status": "success",
"audioId": "17901234567890123",
"title": "Summer Nights",
"displayArtist": "The Example Band",
"durationMs": 32000,
"thumbnailUrl": "https://scontent.example.com/cover.jpg",
"audioType": "music",
"isAdsEligible": true
}
{
"status": "error",
"code": 517,
"action": "post",
"message": "The selected audio track is unavailable. It may be an invalid audio id, restricted in your region, or not licensed for this use. Please choose a different track using the Instagram audio search endpoint and try again.",
"platform": "instagram"
}
可用性因地區而異。 對於不存在的 id、在帳號所在地區未獲授權的 id,
以及未獲此用途授權的 id,Meta 都會回傳相同的錯誤。三種情況都回報
517,因此同一首曲目可能對某個帳號有效,對另一個帳號卻正當地失敗。
請以查詢確認 id,而不要假設先前儲存的 id 仍然可用。錯誤
| Code | 意義 |
|---|---|
| 156 | Instagram 尚未連結至此 Profile。 |
| 161 | Instagram 的授權已過期或被撤銷。請重新連結帳號。 |
| 239 | Instagram 因帳號層級的原因拒絕了請求。 |
| 258 | Instagram 回傳了格式錯誤的回應或未對應的失敗。 |
| 425 | 此連結缺少必要的 Instagram 權限。請重新連結並授予所有權限。 |
| 435 | 已達 Instagram 的速率限制。請稍候再重試。 |
| 514 | Instagram 是以 Instagram Login 連結的。Audio API 需要 Facebook Login。 |
| 516 | audioId 缺少或為空。 |
| 517 | Instagram 無法識別此 id,或此帳號無法使用該曲目。 |