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
Validar un post
Valida un post antes de publicarlo
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."
}
Antes de publicar un post, puedes verificar que el contenido y los parámetros son correctos.
Envía exactamente el mismo JSON que envías normalmente al endpoint
/post al endpoint /validate/post y devolverá una respuesta con los problemas encontrados.
- Pruebas de validación basadas en los propios algoritmos internos de Ayrshare.
- Los posts no se envían a las redes sociales.
- Los posts pueden seguir devolviendo un error desde las redes sociales en el momento de la publicación, incluso con una validación superada.
Parámetros de cabecera
Parámetros del cuerpo
Envía el mismo cuerpo que enviarías al 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
