comments

Post and Manage Comments on a Post

post
Post a Comment

https://app.ayrshare.com/api/comments
Add a comment to a post. Currently only on Facebook and Instagram. Note: Comments required additional permissions. Please unlink and relink Facebook and Instagram in the Developer Dashboard to grant the new permissions. Premium or Business plan required.
Request
Response
Request
Headers
Authorization
optional
string
Format: Authorization: Bearer API_KEY See Overview for more information.
Body Parameters
id
required
string
Post top-level ID.
platforms
required
array
List of platforms to add comments. Currently available platforms: ["facebook", "instagram"]
comment
required
string
Text of the new comment to add to the post.
Response
200: OK
A successful comment added to Facebook and Instagram
{
"facebook": {
"status": "success",
"commentId": "358482752285927_363474831785719",
"comment": "The best comment ever!",
"platform": "facebook"
},
"instagram": {
"status": "success",
"commentId": "17060111860440276",
"comment": "The best comment ever!",
"platform": "instagram"
},
"status": "success",
"id": "Ut1fWU6XkqlMayHGnJZ"
}
404: Not Found
The wrong ID sent and not found.
{
"action": "post",
"status": "error",
"code": 186,
"message": "Post ID not found. Please verify the top level ID returned from the /post endpoint is being sent.",
"id": "Ut1fWU6XkqkMayHGnJ"
}

Request Examples

cURL
Node.js
Python
PHP
Go
C#
cURL
curl \
-H "Authorization: Bearer API_KEY" \
-H 'Content-Type: application/json' \
-d '{"id": "Ut1fWU6XkqkMayHGnJZ", "platforms": ["facebook", "instagram"], "comment": "An amazing comment!"}' \
-X POST https://app.ayrshare.com/api/comments
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/comments", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${API_KEY}`
},
body: JSON.stringify({
id: "Ut1fWU6XkqkMayHGnJZ", // required
platforms: ["facebook", "instagram"], // required
comment: "An amazing comment!", //required
}),
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
payload = {'id': 'Ut1fWU6XkqkMayHGnJZ',
'platforms': ['facebook', 'instagram'],
'comment': 'An amaxing comment!'}
headers = {'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'}
r = requests.post('https://app.ayrshare.com/api/comments',
json=payload,
headers=headers)
print(r.json())
PHP
<?php
require 'vendor/autoload.php'; // Composer auto-loader
$client = new GuzzleHttp\Client(); // Use the HTTP library of your choice
$res = $client->request(
'POST',
'https://app.ayrshare.com/api/comments',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
],
'json' => [
'id' => 'Ut1fWU6XkqkMayHGnJZ', // required
'platforms' => ['facebook', 'instagram'], // required
'comment' => 'An amazing comment!', // required
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
Go
package main
import (
"bytes"
"encoding/json"
"log"
"net/http"
)
func main() {
message := map[string]interface{}{
"id": "Ut1fWU6XkqkMayHGnJZ", // required
"platforms": []string{"facebook", "instagram"}, // required
"comment": []string{"An amazing comment!"} // required
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
req, _ := http.NewRequest("POST", "https://app.ayrshare.com/api/comments",
bytes.NewBuffer(bytesRepresentation))
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Authorization", "Bearer API_KEY")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal("Error:", err)
}
res.Body.Close()
}
C#
using System;
using System.Net;
using System.IO;
namespace PostPOSTRequest_charp
{
class Post
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/comments";
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 = "{\"id\" : \"Ut1fWU6XkqkMayHGnJZ\","
+ "\"platforms\" : [ \"facebook\", \"instagram\"],"
+ "\"comment\" : [ \"An amazing comment!\" ]}";
streamWriter.Write(json);
streamWriter.Flush();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}

get
Get Comments

https://app.ayrshare.com/api/comments
Get the comments for a given top-level post ID. Currently only Facebook and Instagram. Premium or Business plan required.
Request
Response
Request
Path Parameters
id
required
string
Post top-level ID.
Headers
Authorization
required
string
Format: Authorization: Bearer API_KEY See Overview for more information.
Response
200: OK
Successful return of comment data.
{
"facebook": [
{
"from": {
"name": "Wondrous Times",
"id": "112775157855689"
},
"commentId": "158472752285927_358472912285911",
"comment": "What a great comment",
"created": "2021-06-09T20:20:50+0000",
"platform": "facebook"
}
],
"instagram": [
{
"commentId": "11901822970993258",
"comment": "What a great comment",
"created": "2021-06-09T20:22:44+0000",
"platform": "instagram"
}
],
"status": "success",
"id": "Ut2fWU6XkqkMayHGnJZ7"
}
404: Not Found
Comments not found.
{
"action": "post",
"status": "error",
"code": 186,
"message": "Post ID not found. Please verify the top level ID returned from the /post endpoint is being sent.",
"id": "Ut2fWU6XkqkMayHGnJZ7"
}

Request Examples

cURL
Node.js
Python
PHP
C#
cURL
curl \
-H "Authorization: Bearer API_KEY" \
-X GET https://app.ayrshare.com/api/comments?id=Ut1fWU6XkqkMayHGnJZ
Node.js
const fetch = require("node-fetch");
const API_KEY = "API_KEY";
fetch("https://app.ayrshare.com/api/comments?id=Ut1fWU6XkqkMayHGnJZ", {
method: "GET",
headers: {
"Authorization": `Bearer ${API_KEY}`
}
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
Python
import requests
headers = {'Authorization': 'Bearer API_KEY'}
r = requests.get('https://app.ayrshare.com/api/comments?id=Ut1fWU6XkqkMayHGnJZ', headers=headers)
print(r.json())
PHP
<?php
require 'vendor/autoload.php'; // Composer auto-loader
$client = new GuzzleHttp\Client();
$res = $client->request(
'GET',
'https://app.ayrshare.com/api/comments?id=Ut1fWU6XkqkMayHGnJZ',
[
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'Bearer API_KEY'
]
]
);
echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
C#
using System;
using System.Net;
using System.IO;
namespace UserGETRequest_charp
{
class User
{
static void Main(string[] args)
{
string API_KEY = "API_KEY";
string url = "https://app.ayrshare.com/api/comments?id=Ut1fWU6XkqkMayHGnJZ";
var httpWebRequest = WebRequest.CreateHttp(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Headers.Add("Authorization", "Bearer " + API_KEY);
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var response = streamReader.ReadToEnd();
Console.WriteLine(response);
}
}
}
}

Profiles

Get comments or post comments for a particular user profile by passing the profileKey parameter as a path parameter for GET and a body parameter for POST.

GET Path Parameter

https://app.ayrshare.com/api/comments?id=Ut1fWU6XkqkMayHGnJZ&profileKey=JkLs-odKJD-dQPSD-0XJD1

POST Body Parameter

{
profileKey: "JkLs-odKJD-dQPSD-0XJD1"
}