{"status": "success","errors": [],"postIds": [{"status": "success","id": "1288899996423983105","platform": "twitter"},{"status": "success","id": "104923907983682_108329000309742","platform": "facebook"}],"id": "RhrbDtYh7hdSMc67zC8H"}
{"status": "error","errors": [{"action": "post","status": "error","code": 110,"message": "Status is a duplicate.","post": "Today is a great day","platform": "twitter"},{"action": "post","status": "error","code": 107,"message": "Facebook Error: This status update is identical to the last one you posted. Try posting something different, or delete your previous update.","platform": "facebook"}],"postIds": [],"id": "6APU4qqI7XO7JM3BOy6B"}
curl \-H "Authorization: Bearer API_KEY" \-H 'Content-Type: application/json' \-d '{"post": "Today is a great day!", "platforms": ["twitter", "facebook", "instagram", "linkedin"]}, "media_urls": ["https://images.ayrshare.com/imgs/GhostBusters.jpg"], "unsplash": "random"' \-X POST https://app.ayrshare.com/api/post
const fetch = require("node-fetch");const API_KEY = "API_KEY";​fetch("https://app.ayrshare.com/api/post", {method: "POST",headers: {"Content-Type": "application/json","Authorization": `Bearer ${API_KEY}`},body: JSON.stringify({post: "Today is a great day!", // requiredplatforms: ["twitter", "facebook", "instagram", "linkedin"], // requiredmedia_urls: ["https://images.ayrshare.com/imgs/GhostBusters.jpg"], //optionalshorten_links: true, // optionalunsplash: "random", // optional}),}).then((res) => res.json()).then((json) => console.log(json)).catch(console.error);
import requests​payload = {'post': 'Today is a great day!','platforms': ['twitter', 'facebook', 'instagram', 'linkedin'],'media_urls': ['https://images.ayrshare.com/imgs/GhostBusters.jpg'],'unsplash': 'random' }headers = {'Content-Type': 'application/json','Authorization': 'Bearer API_KEY'}​r = requests.post('https://app.ayrshare.com/api/post',json=payload,headers=headers)print(r.json())
<?phprequire 'vendor/autoload.php'; // Composer auto-loader​$client = new GuzzleHttp\Client();$res = $client->request('POST','https://app.ayrshare.com/api/post',['headers' => ['Content-Type' => 'application/json','Authorization' => 'Bearer API_KEY'],'json' => ['post' => 'Today is a great day!','platforms' => ['twitter', 'facebook', 'instagram', 'linkedin'], // required'media_urls' => ['https://images.ayrshare.com/imgs/GhostBusters.jpg'], // optional]]);​echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
package main​import ("bytes""encoding/json""log""net/http")​func main() {message := map[string]interface{}{"post": "Today is a great day!","platforms": []string{"twitter", "facebook", "instagram", "linkedin"},"media_urls": []string{"https://images.ayrshare.com/imgs/GhostBusters.jpg"},"unsplash": "random"}​bytesRepresentation, err := json.Marshal(message)if err != nil {log.Fatalln(err)}​req, _ := http.NewRequest("POST", "https://app.ayrshare.com/api/post",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()}
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/post";​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\" : \"Today is a great day!\","+ "\"platforms\" : [ \"twitter\", \"facebook\", \"instagram\", \"linkedin\" ],"+ "\"media_urls\" : [ \"https://images.ayrshare.com/imgs/GhostBusters.jpg\" ]}";​streamWriter.Write(json);streamWriter.Flush();}​var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();using (var streamReader = new StreamReader(httpResponse.GetResponseStream())){var response = streamReader.ReadToEnd();Console.WriteLine(response);}}}}
Post Facebook Carousel images through Ayrshare's API with the carousel
body parameter.
"carousel": {"link": "URL of See More At...""items": [{"name": "Image name","link": "URL when image clicked","picture": "URL of image"},{"name": "Image name","link": "URL when image clicked","picture": "URL of image"},]}
The top-level link
parameter is the URL at the end of the carousel.
The items is an array of object containing the picture
URL, link
URL when the image is clicked, and name
of the image displayed in each image card. At least two object must be present in the items array.
Note: Do not use the media_urls
with carousel
. If media_urls
is used, carousels
will be ignored.
Please see our Facebook Carousel Blog Post for more information.
Posting to YouTube requires either a paid Premium or Business Plan. The following are required body parameters:
{title: "YouTube Post Title", // Video Titlepost: "YouTube Description", // Video descriptionplatforms: ["youtube"],media_urls: ["https://images.ayrshare.com/imgs/test-video.mp4"], // URL of video, 1 allowedyouTubeVisibility: "unlisted" // "public", "unlisted", or "private"}
​
The following are required body parameters for posting to Reddit. Please be sure the subreddit allows automated posting.
{title: "Reddit Post Title",post: "Reddit post",platforms: ["reddit"],subreddit: "test", // the "/" is not requiredreddit_link: "https://website.com", // Optional, post a link}
Post to on behalf of user by providing users' Profile Keys a a body parameter. Please see here for details. Business Plan required.
​