https://bot-api.targethunter.ru/external-api/v2/attachments/getById
Показывает одно вложение по его ID: вид, имя файла и ссылку на файл.
Нужен личный токен с продуктом BotHunter — как получить. Кому доступен: владельцу сообщества и сотрудникам с ролью «Админ (полный доступ)» или «Рассылки и чат-боты».
| ID вложения — Пример: |
Возвращает объект вложения: вид, имя файла и ссылку на файл.
{
"status": "ok",
"response": {
"id": "65a6e5f4c0e8f20012d3a222",
"type": "photo",
"title": "banner.jpg",
"url": "https://bot-new.targethunter.ru/uploaded/images/65a6e5f4c0e8f20012d3a000/banner.jpg"
}
}Общие ошибки — на странице API.
Код | Когда |
|---|---|
| «Вложение не найдено»: вложения с таким Не передан |
Подставьте свой токен вместо <ваш_токен>.
curl -X POST https://bot-api.targethunter.ru/external-api/v2/attachments/getById \
-H "Authorization: Bearer <ваш_токен>" \
-H "Content-Type: application/json" \
-d '{"attachment_id": "65a6e5f4c0e8f20012d3a222"}'$token = '<ваш_токен>';
$url = 'https://bot-api.targethunter.ru/external-api/v2/attachments/getById';
$params = [
'attachment_id' => '65a6e5f4c0e8f20012d3a222',
];
$curl = curl_init($url);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $token,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($params),
]);
$response = json_decode(curl_exec($curl), true);
curl_close($curl);import requests
token = '<ваш_токен>'
url = 'https://bot-api.targethunter.ru/external-api/v2/attachments/getById'
params = {
'attachment_id': '65a6e5f4c0e8f20012d3a222',
}
response = requests.post(url, json=params, headers={'Authorization': f'Bearer {token}'})
print(response.json())const token = '<ваш_токен>';
const params = {
"attachment_id": "65a6e5f4c0e8f20012d3a222"
};
const response = await fetch('https://bot-api.targethunter.ru/external-api/v2/attachments/getById', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(params),
});
console.log(await response.json());