curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {'Authorization': 'Bearer API_KEY'}
r = requests.get('https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl', headers=headers)
print(r.json())
<?php
// URL and authorization details
$url = 'https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
// Initialize a cURL session
$curl = curl_init();
// Set cURL options
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// Execute cURL session and get the response
$response = curl_exec($curl);
// Check if any error occurred
if(curl_errno($curl)){
echo 'Curl error: ' . curl_error($curl);
} else {
// Decode and re-encode the JSON response to pretty print
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
// Close cURL session
curl_close($curl);
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace PostGETRequest_csharp
{
class Post
{
private static readonly HttpClient client = new HttpClient();
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl";
// Set up request headers
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
try
{
// Send GET request and read response
HttpResponseMessage response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
}
{
"created": "2024-11-19T19:00:14Z",
"errors": [],
"id": "8tNTr73VV8Y66bHwC2322",
"mediaUrls": [
"https://img.ayrshare.com/012/gb.jpg"
],
"platforms": [
"twitter"
],
"post": "#75304 Eighty percent of success is showing up. - John D. Rockefeller",
"postIds": [
{
"status": "success",
"id": "1858948421974925758",
"postUrl": "https://twitter.com/wondrouswaffles/status/185894842197493444",
"platform": "twitter"
}
],
"profileTitle": "Best Profile",
"refId": "b68bdcabb379be2cf1186c1e59544",
"scheduleDate": "2024-11-19T19:00:14Z",
"shortenLinks": false,
"status": "success",
"type": "now"
}
{
"action": "history",
"status": "error",
"code": 221,
"message": "History not found.",
"id": "4W3f3RPr6QSrw8S5Yo8"
}
Post
Get a Post
Truy xuất một bài đăng theo Ayrshare Post ID
GET
/
post
/
:id
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {'Authorization': 'Bearer API_KEY'}
r = requests.get('https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl', headers=headers)
print(r.json())
<?php
// URL and authorization details
$url = 'https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
// Initialize a cURL session
$curl = curl_init();
// Set cURL options
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// Execute cURL session and get the response
$response = curl_exec($curl);
// Check if any error occurred
if(curl_errno($curl)){
echo 'Curl error: ' . curl_error($curl);
} else {
// Decode and re-encode the JSON response to pretty print
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
// Close cURL session
curl_close($curl);
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace PostGETRequest_csharp
{
class Post
{
private static readonly HttpClient client = new HttpClient();
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl";
// Set up request headers
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
try
{
// Send GET request and read response
HttpResponseMessage response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
}
{
"created": "2024-11-19T19:00:14Z",
"errors": [],
"id": "8tNTr73VV8Y66bHwC2322",
"mediaUrls": [
"https://img.ayrshare.com/012/gb.jpg"
],
"platforms": [
"twitter"
],
"post": "#75304 Eighty percent of success is showing up. - John D. Rockefeller",
"postIds": [
{
"status": "success",
"id": "1858948421974925758",
"postUrl": "https://twitter.com/wondrouswaffles/status/185894842197493444",
"platform": "twitter"
}
],
"profileTitle": "Best Profile",
"refId": "b68bdcabb379be2cf1186c1e59544",
"scheduleDate": "2024-11-19T19:00:14Z",
"shortenLinks": false,
"status": "success",
"type": "now"
}
{
"action": "history",
"status": "error",
"code": 221,
"message": "History not found.",
"id": "4W3f3RPr6QSrw8S5Yo8"
}
Lấy lịch sử của một bài đăng cụ thể được gửi qua Ayrshare. Trả về trạng thái, các tham số của bài đăng và các chi tiết khác. Thay
:id bằng Ayrshare Post ID.
Gọi endpoint /history by id để lấy cùng dữ liệu.
Trạng thái bài đăng
Các trạng thái sau được trả về cho một bài đăng.| Trạng thái | Mô tả |
|---|---|
awaiting approval | Các bài đăng đang chờ được duyệt qua quy trình phê duyệt. |
deleted | Bài đăng đã bị xóa. Lưu ý: các bài đăng đã xóa chỉ được trả về với bộ lọc truy vấn status. Xem bên dưới. |
error | Đã xảy ra lỗi với một hoặc nhiều mạng xã hội. |
pending | Bài đăng chưa được xử lý. Thường là một bài đăng đã lên lịch. |
success | Bài đăng đã được gửi thành công đến tất cả các mạng xã hội. |
Xem endpoint /history để truy xuất tất cả các bài đăng, bao gồm
cả các bài đăng không được gửi qua Ayrshare.
Tham số Header
Tham số Path
Ayrshare Post ID từ /post
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {'Authorization': 'Bearer API_KEY'}
r = requests.get('https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl', headers=headers)
print(r.json())
<?php
// URL and authorization details
$url = 'https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl';
$apiKey = 'API_KEY'; // Replace 'API_KEY' with your actual API key
// Initialize a cURL session
$curl = curl_init();
// Set cURL options
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// Execute cURL session and get the response
$response = curl_exec($curl);
// Check if any error occurred
if(curl_errno($curl)){
echo 'Curl error: ' . curl_error($curl);
} else {
// Decode and re-encode the JSON response to pretty print
echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
}
// Close cURL session
curl_close($curl);
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace PostGETRequest_csharp
{
class Post
{
private static readonly HttpClient client = new HttpClient();
static async Task Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://api.ayrshare.com/api/post/TBEAAqAMMJoweA9wKHUl";
// Set up request headers
client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
try
{
// Send GET request and read response
HttpResponseMessage response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error: {e.Message}");
}
}
}
}
{
"created": "2024-11-19T19:00:14Z",
"errors": [],
"id": "8tNTr73VV8Y66bHwC2322",
"mediaUrls": [
"https://img.ayrshare.com/012/gb.jpg"
],
"platforms": [
"twitter"
],
"post": "#75304 Eighty percent of success is showing up. - John D. Rockefeller",
"postIds": [
{
"status": "success",
"id": "1858948421974925758",
"postUrl": "https://twitter.com/wondrouswaffles/status/185894842197493444",
"platform": "twitter"
}
],
"profileTitle": "Best Profile",
"refId": "b68bdcabb379be2cf1186c1e59544",
"scheduleDate": "2024-11-19T19:00:14Z",
"shortenLinks": false,
"status": "success",
"type": "now"
}
{
"action": "history",
"status": "error",
"code": 221,
"message": "History not found.",
"id": "4W3f3RPr6QSrw8S5Yo8"
}
⌘I
