curl --location "https://api.ayrshare.com/api/validate/post" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer API_KEY" \
--data '{
"post": "This is amazing",
"platforms": [
"facebook"
],
"mediaUrls": ["https://img.ayrshare.com/012/gb.jpg"]
}'
const apiKey = 'API_KEY'; // Replace with your actual API key
const requestData = {
post: "This is amazing",
platforms: ["facebook"],
mediaUrls: ["https://img.ayrshare.com/012/gb.jpg"]
};
fetch('https://api.ayrshare.com/api/validate/post', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`
},
body: JSON.stringify(requestData)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
payload = {
'post': 'This is amazing',
'platforms': ['facebook'],
'mediaUrls': ['https://img.ayrshare.com/012/gb.jpg']
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'
}
r = requests.post(
'https://api.ayrshare.com/api/validate/post',
json=payload,
headers=headers
)
print(r.json())
<?php
$payload = [
'post' => 'This is amazing',
'platforms' => ['facebook'],
'mediaUrls' => ['https://img.ayrshare.com/012/gb.jpg']
];
$headers = [
'Content-Type: application/json',
'Authorization: Bearer API_KEY'
];
$ch = curl_init('https://api.ayrshare.com/api/validate/post');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var payload = new
{
post = "This is amazing",
platforms = new[] { "facebook" },
mediaUrls = new[] { "https://img.ayrshare.com/012/gb.jpg" }
};
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
try
{
var response = await client.PostAsJsonAsync(
"https://api.ayrshare.com/api/validate/post",
payload
);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
)
type PostRequest struct {
Post string `json:"post"`
Platforms []string `json:"platforms"`
MediaUrls []string `json:"mediaUrls"`
}
func main() {
// Create the request payload
payload := PostRequest{
Post: "This is amazing",
Platforms: []string{"facebook"},
MediaUrls: []string{"https://img.ayrshare.com/012/gb.jpg"},
}
// Convert payload to JSON
jsonData, err := json.Marshal(payload)
if err != nil {
log.Fatalf("Error marshaling JSON: %v", err)
}
// Create the request
req, err := http.NewRequest(
"POST",
"https://api.ayrshare.com/api/validate/post",
bytes.NewBuffer(jsonData),
)
if err != nil {
log.Fatalf("Error creating request: %v", err)
}
// Set headers
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer API_KEY")
// Make the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Fatalf("Error making request: %v", err)
}
defer resp.Body.Close()
// Read the response
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatalf("Error reading response: %v", err)
}
// Print the response
fmt.Println(string(body))
}
{
"status": "success",
"message": "No validation issues were found with this post. This is only an Ayrshare validation test and the post may still return an error by the social networks.",
}
{
"status": "success",
"message": "No validation issues were found with this post. This is only an Ayrshare validation test and the post may still return an error by the social networks.",
"warnings": [
{
"action": "post",
"status": "error",
"code": 156,
"message": "Twitter is not linked with Ayrshare. Please confirm the linkage on the Social Accounts page in your dashboard."
}
]
}
{
"action": "post",
"status": "error",
"code": 136,
"message": "Media URLs invalid. Please verify the media is an externally accessible URL."
}
Validate
Xác thực bài đăng
Xác thực một bài đăng trước khi đăng
POST
/
validate
/
post
curl --location "https://api.ayrshare.com/api/validate/post" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer API_KEY" \
--data '{
"post": "This is amazing",
"platforms": [
"facebook"
],
"mediaUrls": ["https://img.ayrshare.com/012/gb.jpg"]
}'
const apiKey = 'API_KEY'; // Replace with your actual API key
const requestData = {
post: "This is amazing",
platforms: ["facebook"],
mediaUrls: ["https://img.ayrshare.com/012/gb.jpg"]
};
fetch('https://api.ayrshare.com/api/validate/post', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`
},
body: JSON.stringify(requestData)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
payload = {
'post': 'This is amazing',
'platforms': ['facebook'],
'mediaUrls': ['https://img.ayrshare.com/012/gb.jpg']
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'
}
r = requests.post(
'https://api.ayrshare.com/api/validate/post',
json=payload,
headers=headers
)
print(r.json())
<?php
$payload = [
'post' => 'This is amazing',
'platforms' => ['facebook'],
'mediaUrls' => ['https://img.ayrshare.com/012/gb.jpg']
];
$headers = [
'Content-Type: application/json',
'Authorization: Bearer API_KEY'
];
$ch = curl_init('https://api.ayrshare.com/api/validate/post');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var payload = new
{
post = "This is amazing",
platforms = new[] { "facebook" },
mediaUrls = new[] { "https://img.ayrshare.com/012/gb.jpg" }
};
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
try
{
var response = await client.PostAsJsonAsync(
"https://api.ayrshare.com/api/validate/post",
payload
);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
)
type PostRequest struct {
Post string `json:"post"`
Platforms []string `json:"platforms"`
MediaUrls []string `json:"mediaUrls"`
}
func main() {
// Create the request payload
payload := PostRequest{
Post: "This is amazing",
Platforms: []string{"facebook"},
MediaUrls: []string{"https://img.ayrshare.com/012/gb.jpg"},
}
// Convert payload to JSON
jsonData, err := json.Marshal(payload)
if err != nil {
log.Fatalf("Error marshaling JSON: %v", err)
}
// Create the request
req, err := http.NewRequest(
"POST",
"https://api.ayrshare.com/api/validate/post",
bytes.NewBuffer(jsonData),
)
if err != nil {
log.Fatalf("Error creating request: %v", err)
}
// Set headers
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer API_KEY")
// Make the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Fatalf("Error making request: %v", err)
}
defer resp.Body.Close()
// Read the response
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatalf("Error reading response: %v", err)
}
// Print the response
fmt.Println(string(body))
}
{
"status": "success",
"message": "No validation issues were found with this post. This is only an Ayrshare validation test and the post may still return an error by the social networks.",
}
{
"status": "success",
"message": "No validation issues were found with this post. This is only an Ayrshare validation test and the post may still return an error by the social networks.",
"warnings": [
{
"action": "post",
"status": "error",
"code": 156,
"message": "Twitter is not linked with Ayrshare. Please confirm the linkage on the Social Accounts page in your dashboard."
}
]
}
{
"action": "post",
"status": "error",
"code": 136,
"message": "Media URLs invalid. Please verify the media is an externally accessible URL."
}
Trước khi đăng một bài đăng, bạn có thể xác minh nội dung và các tham số là chính xác.
Gửi cùng một JSON mà bạn thường gửi đến endpoint
/post đến endpoint /validate/post và nó sẽ trả về phản hồi với bất kỳ vấn đề nào được tìm thấy.
- Các kiểm tra xác thực dựa trên thuật toán nội bộ riêng của Ayrshare.
- Bài đăng không được gửi đến các mạng xã hội.
- Bài đăng vẫn có thể trả về lỗi từ các mạng xã hội tại thời điểm đăng, ngay cả khi đã vượt qua xác thực.
Tham số Header
Tham số Body
Gửi cùng body như bạn sẽ gửi đến endpoint /post.curl --location "https://api.ayrshare.com/api/validate/post" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer API_KEY" \
--data '{
"post": "This is amazing",
"platforms": [
"facebook"
],
"mediaUrls": ["https://img.ayrshare.com/012/gb.jpg"]
}'
const apiKey = 'API_KEY'; // Replace with your actual API key
const requestData = {
post: "This is amazing",
platforms: ["facebook"],
mediaUrls: ["https://img.ayrshare.com/012/gb.jpg"]
};
fetch('https://api.ayrshare.com/api/validate/post', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`
},
body: JSON.stringify(requestData)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
import requests
payload = {
'post': 'This is amazing',
'platforms': ['facebook'],
'mediaUrls': ['https://img.ayrshare.com/012/gb.jpg']
}
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'
}
r = requests.post(
'https://api.ayrshare.com/api/validate/post',
json=payload,
headers=headers
)
print(r.json())
<?php
$payload = [
'post' => 'This is amazing',
'platforms' => ['facebook'],
'mediaUrls' => ['https://img.ayrshare.com/012/gb.jpg']
];
$headers = [
'Content-Type: application/json',
'Authorization: Bearer API_KEY'
];
$ch = curl_init('https://api.ayrshare.com/api/validate/post');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true);
print_r($result);
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var payload = new
{
post = "This is amazing",
platforms = new[] { "facebook" },
mediaUrls = new[] { "https://img.ayrshare.com/012/gb.jpg" }
};
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
try
{
var response = await client.PostAsJsonAsync(
"https://api.ayrshare.com/api/validate/post",
payload
);
response.EnsureSuccessStatusCode();
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
catch (HttpRequestException ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
)
type PostRequest struct {
Post string `json:"post"`
Platforms []string `json:"platforms"`
MediaUrls []string `json:"mediaUrls"`
}
func main() {
// Create the request payload
payload := PostRequest{
Post: "This is amazing",
Platforms: []string{"facebook"},
MediaUrls: []string{"https://img.ayrshare.com/012/gb.jpg"},
}
// Convert payload to JSON
jsonData, err := json.Marshal(payload)
if err != nil {
log.Fatalf("Error marshaling JSON: %v", err)
}
// Create the request
req, err := http.NewRequest(
"POST",
"https://api.ayrshare.com/api/validate/post",
bytes.NewBuffer(jsonData),
)
if err != nil {
log.Fatalf("Error creating request: %v", err)
}
// Set headers
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer API_KEY")
// Make the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Fatalf("Error making request: %v", err)
}
defer resp.Body.Close()
// Read the response
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatalf("Error reading response: %v", err)
}
// Print the response
fmt.Println(string(body))
}
{
"status": "success",
"message": "No validation issues were found with this post. This is only an Ayrshare validation test and the post may still return an error by the social networks.",
}
{
"status": "success",
"message": "No validation issues were found with this post. This is only an Ayrshare validation test and the post may still return an error by the social networks.",
"warnings": [
{
"action": "post",
"status": "error",
"code": 156,
"message": "Twitter is not linked with Ayrshare. Please confirm the linkage on the Social Accounts page in your dashboard."
}
]
}
{
"action": "post",
"status": "error",
"code": 136,
"message": "Media URLs invalid. Please verify the media is an externally accessible URL."
}
⌘I
