Facebook Page
Options for posting via the API to a Facebook Page
Posting to Facebook via the API requires connecting a Facebook Page. Facebook does not allow personal accounts to be connected.
JSON for a basic post with a link and image to a Facebook page:
{
"post": "The best FB post ever #best https://www.facebook.com",
"mediaUrls": ["https://img.ayrshare.com/012/gb.jpg"],
"platforms": ["facebook"]
}
- Facebook will automatically preview the link in the post unless there is an image or video included. In the above example the image will show. Removing the image will cause the link preview to show.
- If your video doesn't end in a known video extension such as mp4, please use the
isVideo
parameter. See the /post endpoint for details. - Facebook also supports sending media without post text. If you do not want post text included send an empty String
post: ""
Post Facebook Carousel images through Ayrshare's API with the
carousel
body parameter.{
"faceBookOptions": {
"carousel": {
"link": "URL of See More At...", // The URL of the "See More At" button
"items": [ // 2 min, 10 max elements in the array
{
"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 following values. Minimum 2 elements and max 10 elements in the items array.picture
- URL of the carousel image.link
- URL when the image is clicked.name
- image displayed in each image card.
Note: Do not use the
media_urls
with carousel
. If media_urls
is used, carousels
will be ignored.A Premium or Business Plan is required for carousel posting.
You can post a video to Facebook Reels API with the following
facebookOptions
.{
"post": "The description of the video",
"platforms": ["facebook"],
"mediaUrls": ["https://img.ayrshare.com/012/reel.mp4"],
"faceBookOptions": {
"reels": true,
"title": "Super title for the Reel" // optional
}
}
reels
: Set totrue
to post the video to Reels.title
: .The title of the video with maximum of 255 characters. Over 255 characters will be truncated. Optional.
Set a caption for each Facebook media image posted.
Accepts an array of string caption text. Each array must correspond to a media url. E.g. ["This is my best pic", "😃 here is the next one"] refers to the 1st and 2nd urls in
mediaUrls
.{
"faceBookOptions": {
"mediaCaptions": ["This is my best pic", "😃 here is the next one"]
}
}
Add alternative text, also known as alt text, to a Facebook image or video. Facebook alt text is an accessibility feature used for additional user info and screen readers.
Use the
altText
in the faceBookOptions
object."faceBookOptions": {
"altText": ["This is my best pic", "😃 here is the next one"] // Array of Alt Texts
}
Each alt text must correspond to an image or video in the
mediaUrls
array. The alt text will be applies to each image in order.Set a thumbnail for a video. Send a remote URL of a PNG or JPG file that is the same dimensions as the video and less than 10 MB. URL should end in .png or .jpg.
{
"faceBookOptions": {
"thumbNail": "https://octodex.github.com/images/Fintechtocat.png"
}
}
Add a title to the video with the
title
parameter.{
"faceBookOptions": {
"title": "The best video ever!"
}
}
Only one URL is allowed with a Facebook animated GIF. If the media URL does not end in ".gif" or ".GIF", set the
isVideo
field to true
.{
"randomPost": true,
"platforms": [
"facebook"
],
"isVideo": false, // Set to true if the mediaURL does not end in .gif or .GIF
"mediaUrls": ["https://img.ayrshare.com/012/cat.gif"]
}
You can mention another Facebook Page, also known as Facebook Tagging, by including the Facebook Page name or Page ID in the post text. Facebook does not allow mentions or tags of personal profiles or groups.
Note: Premium or Business Plan required for mentions.
Include a mention with the following @mention:
@page-name
or @[page-id]
An example post text with a Page name. You can find the Page name from the Facebook URL, e.g. https://www.facebook.com/Ayrshare
"post": "This is the best social media api by @Ayrshare"
Ayrshare will make a best attempt to find the matching Page based on the name, but sometimes a match can not be found. A more reliable method is using a Page ID.
An example post text with a Page ID, note the use of []. Please see below on how to find the Page ID.
"post": "This is the best social media api by @[738681876342836]"
The Facebook Page ID will resolve to the matching page and notify the Page mentioned.
Use Page mentioning with caution by only mentioning Pages you are associated with and never spam.
When you mention a Page, the owner of the Page will be notified via an alert and email. If several Pages complain about you mentioning them, Facebook could possibly ban your account. Please be sure to only tag Pages that you have an established relationship.
The Facebook Page being mentioned must allow other Pages to mention/tag their Page. Mentions can be enabled in the Page's general settings under "Others Tag this Page".
- 1.From News Feed, click Pages in the left side menu.
- 2.Click your Page name to go to your Page.
- 3.Click About at the top of your Page. If you don't see it, click More.
- 4.Scroll down to find your Page ID below MORE INFO.
or if you want to find the ID of a page your don't own:
- If the Facebook Page has a URL such as
https://www.facebook.com/ayrshare-1234567890
then the ID is 1234567890. - If the Facebook Page has a URL such as:
https://www.facebook.com/pages/ayrshare/123466789203
then the Page ID is the number at the end, such as 123466789203.
You can test that the Page ID is correct by going to
https://facebook.com/page-id
and it will resolve to the Page.You can also try a 3rd party Facebook Page look up tool, which is not supported by Ayrshare, such as: https://lookup-id.com/
If all other methods fail, you can go to the Facebook page in a browser and view the page source. In Chrome, right click to select "View Source". Then search for either
owning_profile_id
or profile_id
to find the Page ID.Create a draft post that appears in the Meta Business Suite Draft tab. Facebook draft posts are posts that you have started writing, but have not yet published. You can save draft posts to come back to later, or you can schedule them to be published at a later date.
Add the
draft
parameter to faceBookOptions
to send the post as a draft.{
"faceBookOptions": {
"draft": true
}
}
Set a schedule publish time for Facebook posts that appear in the Meta Business Suite Scheduled Posts tab. Facebook scheduled posts are posts that you have created and scheduled to be published at a later date and are managed in the Meta Business Suite. This can be useful for planning your social media posts in advance, or for publishing posts at times when you know your audience is most active.
Unless you need to manage Facebook posts in Meta Business Suite, we recommend using the standard post schedule date.
Add the
scheduledPublishDate
parameter to faceBookOptions
to schedule a post time.{
"faceBookOptions": {
"scheduledPublishDate": "2023-09-28T21:44:06Z" // Future date in UTC
}
}
A Facebook post will automatically create a link preview of a link in the post body. However, if you want to specify either a different link or force the link preview, use the
link
parameter with URL of the link."faceBookOptions": {
"link": "https://www.ayrshare.com/instagram-hashtag-guide/"
}
Rich text, such as bold or italic lettering, can be added to a Facebook post with a few html elements.
Don't worry, it only shows in the admin view. Please see the troubleshooting guide for more information.
Facebook Stories posting is not yet supported by Facebook's official API integration. However Facebook Reels, Instagram Reels, and Instagram Stories can be posted via Ayrshare's API.
Last modified 3d ago