Publish Group Feed, Photos, and Videos
Learn how to publish posts, photos, and videos in a group.
We'll cover the following
Publish feed
The feed on a Facebook group is the stream of posts that the members of the group share. Group members use the feed to share news and updates, ask questions, or start discussions on various topics. Users can view and interact with the feed by visiting the group, scrolling through the posts, and engaging in discussions. The feed is an excellent way for group members to stay informed and up-to-date on the group's activity and discussion. It also serves as a way for members to connect and engage with one another, making it a valuable tool for building and fostering a community. The feed is the central hub of activity and communication within the group.
The base URL for this endpoint is:
https://graph.facebook.com/v16.0/{group_id}/feed
Request Parameters
Parameter | Type | Category | Description |
| String | Mandatory | This is the token that we received after app authentication and authorization. |
| String | Optional | These are the fields we want in the response from the API call. |
| String | Mandatory | This is the ID of the group. Note that this is a path parameter. |
| String | Optional | This is the text of the post. This parameter is required if we're publishing a plaintext post. |
| String | Optional | This is the URL that will be included in the post. If we include a link, the |
| String | Optional | This is the name of the link that will be included in the post. |
| String | Optional | This is the caption of the link that will be included in the post. |
| String | Optional | This is the description of the link that will be included in the post. |
| Array | Optional | This is a comma-separated list of user IDs of people tagged in the post. |
| String | Optional | This is the ID of a previously-uploaded photo or video to use as the primary content for the post. |
To publish a post on a Facebook group using the Graph API, we need to make a POST
request to the /{group_id}/feed
endpoint using a user access token with the publish_to_groups
permission. The code below uses the endpoint above. Click the “Run” button to see the response.
// Importing libraries hereimport fetch from "node-fetch"// Define endpoint URL hereconst endpointUrl = new URL("https://graph.facebook.com/v16.0/{{GROUP_ID}}/feed");const headerParameters = {contentType: "application/json",};// Setting API call optionsconst options = {method: "POST",headers: headerParameters,};// Define Query Parameters hereconst queryParameters = new URLSearchParams({access_token: '{{USER_ACCESS_TOKEN}}',message: 'This is a test message'});// Function to make API callasync function publishNewPost() {try {endpointUrl.search = queryParameters;const response = await fetch(endpointUrl, options);// Printing responseprintResponse(response);} catch (error) {// Printing error messageprintError(error);}}// Calling function to make API callpublishNewPost();
In the code widget above:
Line 5: We define the endpoint URL in the
endpointUrl
variable.Lines 18–21: We add the
access_token
and specify themessage
in thequeryParameters
variable.Line 27: We use the
fetch
function to make the API call.
Response Fields
Name | Type | Description |
| String | This is the ID of the post. |
| String | This is the time when the post was created. The time is in ISO 8601 format. |
| Object | This is the object containing the ID and name of the user or page that created the post. |
| Object | This is the object containing the ID and name of the group where the post was made. |
Note: In order to view the feed, we will make a
GET
request to the same endpoint.
Publish photo
Photos on a Facebook group are a way for group members to share pictures and visual content with the group. Users can use them to share updates, memories, or other types of content. Photos can be a great way for group members to connect and engage with one another visually. Posting photos is also a great way to create and maintain a visual history of the group's activities and for businesses to showcase their products. The base URL for this endpoint is:
https://graph.facebook.com/v16.0/{group_id}/photos
Request Parameters
Parameter | Type | Category | Description |
| String | Mandatory | This is the token that we received after app authentication and authorization. |
| String | Mandatory | This is the group's ID. Note that this is a path parameter. |
| String | Optional | This is the binary file of the photo to be uploaded. |
| String | Optional | This is the caption of the photo. |
| Boolean | Optional | This indicates whether the photo should be published immediately or be saved as a draft. |
| String | Optional | This is the ID of the Facebook page of the location associated with this photo. |
To publish a new photo on the group using the Facebook Graph API, we can make a POST
request to the photos
edge of the group
object using the group's ID and user access token with the publish_to_groups
permission. Click the “Run” button to see the response.
// Importing libraries hereimport fetch from "node-fetch";import fs from 'fs';import {FormData, Blob} from "formdata-node"// Define endpoint URL hereconst endpointUrl = new URL("https://graph.facebook.com/v16.0/{{GROUP_ID}}/photos");const headerParameters = {contentType: "application/json",};// Photo Pathconst photo = fs.readFileSync('Educative-Thumbnail.png');// Define Query Parameters hereconst queryParameters = new URLSearchParams({access_token: '{{USER_ACCESS_TOKEN}}',});const body = new FormData();body.append('caption', 'This is a sample photo');body.append('photo', new Blob([photo]), 'photo.png');// Setting API call optionsconst options = {method: "POST",headers: headerParameters,body: body};// Function to make API callasync function postPhotoOnGroup() {try {endpointUrl.search = queryParameters;const response = await fetch(endpointUrl, options);// Printing responseprintResponse(response);} catch (error) {// Printing error messageprintError(error);}}// Calling function to make API callpostPhotoOnGroup();
In the code widget above:
Line 7: We define the endpoint URL in the
endpointUrl
variable.Line 14: We read the photo using the
readFileSync
function of thefs
library.Lines 17–19: We add the
access_token
in thequeryParameters
variable.Lines 21–23: We create a
FormData
and append thecaption
andphoto
to it.Line 36: We use the
fetch
function to make the API call.
Response Fields
Name | Type | Description |
| String | This is the ID of the photo. |
| String | This is the time when the photo was created. The time is in ISO 8601 format. |
| Object | This is the object containing the ID and name of the user or page that uploaded the photo. |
Publish video
Videos on a Facebook group are a way for members to share video content with the group. Members can use videos to share updates, demonstrations, tutorials, or other types of content. Videos are an excellent way for group members to express themselves creatively and share experiences and information dynamically and engagingly. Businesses or organizations can use videos to demonstrate products and services or to showcase behind-the-scenes happenings. The base URL for this endpoint is:
https://graph.facebook.com/v16.0/{group_id}/videos
Request Parameters
Parameter | Type | Category | Description |
| String | Mandatory | This is the token that we received in response after making the call to the |
| String | Mandatory | This is the group's ID. Note that this is a path parameter. |
| String | Optional | This is the title of the video. |
| String | Optional | This is the description of the video. |
| String | Mandatory | This is the binary form of the video file we want to upload on the group. |
| String | Optional | This indicates whether the video should be published immediately or be saved as a draft. |
To publish a new video on the group using the Facebook Graph API, we can make a POST
request to the videos
edge of the group
object using the group's ID and user access token that has the publish_to_groups
permission. Click the “Run” button to see the response.
// Importing libraries hereimport fetch from "node-fetch";import fs from 'fs';import {FormData, Blob} from "formdata-node"// Define endpoint URL hereconst endpointUrl = new URL("https://graph.facebook.com/v16.0/{{GROUP_ID}}/videos");const headerParameters = {contentType: "application/json",};// Video Pathconst videoFile = fs.readFileSync('Welcome_to_Educative.mp4');// Define Query Parameters hereconst queryParameters = new URLSearchParams({access_token: '{{USER_ACCESS_TOKEN}}',});const body = new FormData();body.append('description', 'This is a sample video');body.append('video_file', new Blob([videoFile]), 'video.mp4');// Setting API call optionsconst options = {method: "POST",headers: headerParameters,body: body};// Function to make API callasync function postVideoOnGroup() {try {endpointUrl.search = queryParameters;const response = await fetch(endpointUrl, options);// Printing responseprintResponse(response);} catch (error) {// Printing error messageprintError(error);}}// Calling function to make API callpostVideoOnGroup();
In the code widget above:
Line 7: We define the endpoint URL in the
endpointUrl
variable.Line 14: We read the video file using the
readFileSync
function of thefs
library.Lines 17–19: We add the
access_token
in thequeryParameters
variable.Lines 21–23: We create a
FormData
and append thedescription
andvideo_file
to it.Line 36: We use the
fetch
function to make the API call.
Response Fields
Name | Type | Description |
| String | This is the ID of the video. |
| String | This is the description of the video. |
| Object | This is the object containing the ID and name of the user or page that posted the video. |
| String | This is the title of the video. |
| String | This is the video file's URL. |
| String | This is the time when the video was created. The time is in ISO 8601 format. |
| String | This is the time when the video was updated. This time is in ISO 8601 format. |