Comment on page
validate
Validate Social Posts and JSON
Required a Premium or Business Plan.
The following endpoints validate social posts and a JSON objects.
post
https://app.ayrshare.com/api
/validate/post
Validate a Post
post
https://app.ayrshare.com/api
/validate/json
Validate JSON
- Send data as text. If using Postman, please be sure to select "Text" as the type.
- Set the
"Content-Type": "text/plain"
.
An example of invalid JSON using Postman. Can you spot it? A missing comma at the end on the second parameter
platforms
. Be sure to set the
Content-Type
in the header as text/plain
and select "Text" when sending.
Postman Validate JSON
post
https://app.ayrshare.com/api
/validate/postLength
Check Post Length
cURL
Node.js
Python
PHP
C#
curl \
-H "Authorization: Bearer API Key" \
-H 'Content-Type: application/json' \
-d '{"post": "🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩"}' \
-X POST https://app.ayrshare.com/api/post/checkPostWeight
const API_KEY = "API_KEY";
const post = "🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩";
fetch("https://app.ayrshare.com/api/post/checkPostWeight", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({ post }),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {'post': '🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://app.ayrshare.com/api/post/checkPostWeight',
json=payload,
headers=headers)
print(r.json())
<?php
require 'vendor/autoload.php'; // Composer auto-loader using Guzzle. See https://docs.guzzlephp.org/en/stable/overview.html
$client = new GuzzleHttp\Client();
$res = $client->request(
'POST',
'https://app.ayrshare.com/api/post/checkPostWeight',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'post' => ['🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩 🍩🍩🍩🍩🍩🍩🍩🍩']
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
using System;
using System.Net;
using System.IO;
namespace CheckPostWeightRequest_charp
{
class Post
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/post/checkPostWeight";
var httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{\"post\" : \"🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩🍩\"}";
streamWriter.Write(json);
streamWriter.Flush();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}
Last modified 6mo ago