Lấy metadata audio 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
Lấy metadata audio Instagram
Tra cứu chi tiết của một bản nhạc audio Instagram theo id của nó
GET
/
media
/
instagram
/
audio
/
{audioId}
Lấy metadata audio 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"
}
Truy xuất chi tiết của một bản nhạc audio theo
Các mã 514 đến 518 được mô tả trong Lỗi audio Instagram Reels; các mã còn lại nằm trong tài liệu tham khảo lỗi Ayrshare.
audioId của nó. Sử dụng endpoint này để xác nhận một id đã lưu vẫn còn hợp lệ, hoặc để hiển thị tiêu đề và ảnh bìa của một bản nhạc trước khi xuất bản.
Tham số Header
Tham số Path
string
bắt buộc
Id của bản nhạc, như được trả về bởi tìm kiếm audio. Một id
Instagram không nhận diện trả về
code: 517.Trường Phản hồi
Các trường của bản nhạc được trả về phẳng trên đối tượng phản hồi thay vì lồng nhau. Instagram không trả về mọi trường cho mọi bản nhạc, vì vậy hãy coi tất cả các trường ngoại trừaudioId là tùy chọn.
string
success khi bản nhạc được tìm thấy.string
Id của bản nhạc, được trả lại nguyên trạng.
string
Tiêu đề bản nhạc.
string
Tên nghệ sĩ như Instagram hiển thị.
integer
Độ dài bản nhạc tính bằng mili giây.
string
URL thumbnail của ảnh bìa.
string
Hoặc
music hoặc original_sound.boolean
Liệu bản nhạc có thể được sử dụng trong quảng cáo hay không.
{
"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"
}
Tính khả dụng phụ thuộc vào khu vực. Meta trả về cùng một lỗi cho một id không tồn tại, một id
không được cấp phép trong khu vực của tài khoản, và một id không được cấp phép cho mục đích sử dụng
này. Cả ba đều báo
517, nên một bản nhạc dùng được với tài khoản này có thể thất bại một cách
hợp lệ với tài khoản khác. Hãy tra cứu một id thay vì mặc định rằng một id đã lưu vẫn hoạt động.Lỗi
| Mã | Ý nghĩa |
|---|---|
| 156 | Instagram chưa được liên kết với profile này. |
| 161 | Ủy quyền của Instagram đã hết hạn hoặc bị thu hồi. Liên kết lại tài khoản. |
| 239 | Instagram đã từ chối yêu cầu vì một lý do ở cấp tài khoản. |
| 258 | Instagram trả về một phản hồi bị lỗi định dạng hoặc một thất bại chưa được ánh xạ. |
| 425 | Kết nối thiếu một quyền Instagram bắt buộc. Liên kết lại và cấp tất cả các quyền. |
| 435 | Đã đạt tới giới hạn tốc độ của Instagram. Chờ trước khi thử lại. |
| 514 | Instagram được liên kết bằng Instagram Login. Audio API yêu cầu Facebook Login. |
| 516 | audioId bị thiếu hoặc rỗng. |
| 517 | Instagram không nhận diện id, hoặc bản nhạc không khả dụng với tài khoản này. |