Publish Group Feed, Photos, and Videos

Learn how to publish posts, photos, and videos in a group.

Publish feed

Group feed
Group 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

access_token

String

Mandatory

This is the token that we received after app authentication and authorization.

fields

String

Optional

These are the fields we want in the response from the API call.

group_id

String

Mandatory

This is the ID of the group. Note that this is a path parameter.

message

String

Optional

This is the text of the post. This parameter is required if we're publishing a plaintext post.

link

String

Optional

This is the URL that will be included in the post. If we include a link, the message parameter is not required.

name

String

Optional

This is the name of the link that will be included in the post.

caption

String

Optional

This is the caption of the link that will be included in the post.

description

String

Optional

This is the description of the link that will be included in the post.

tags

Array

Optional

This is a comma-separated list of user IDs of people tagged in the post.

object_attachment

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.

Press + to interact
// Importing libraries here
import fetch from "node-fetch"
// Define endpoint URL here
const endpointUrl = new URL("https://graph.facebook.com/v16.0/{{GROUP_ID}}/feed");
const headerParameters = {
contentType: "application/json",
};
// Setting API call options
const options = {
method: "POST",
headers: headerParameters,
};
// Define Query Parameters here
const queryParameters = new URLSearchParams({
access_token: '{{USER_ACCESS_TOKEN}}',
message: 'This is a test message'
});
// Function to make API call
async function publishNewPost() {
try {
endpointUrl.search = queryParameters;
const response = await fetch(endpointUrl, options);
// Printing response
printResponse(response);
} catch (error) {
// Printing error message
printError(error);
}
}
// Calling function to make API call
publishNewPost();

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 the message in the queryParameters variable.

  • Line 27: We use the fetch function to make the API call.

Response Fields

Name

Type

Description

id

String

This is the ID of the post.

created_time

String

This is the time when the post was created. The time is in ISO 8601 format.

from

Object

This is the object containing the ID and name of the user or page that created the post.

to

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

access_token

String

Mandatory

This is the token that we received after app authentication and authorization.

group_id

String

Mandatory

This is the group's ID. Note that this is a path parameter.

photo

String

Optional

This is the binary file of the photo to be uploaded.

caption

String

Optional

This is the caption of the photo.

published

Boolean

Optional

This indicates whether the photo should be published immediately or be saved as a draft.

place

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.

Press + to interact
// Importing libraries here
import fetch from "node-fetch";
import fs from 'fs';
import {FormData, Blob} from "formdata-node"
// Define endpoint URL here
const endpointUrl = new URL("https://graph.facebook.com/v16.0/{{GROUP_ID}}/photos");
const headerParameters = {
contentType: "application/json",
};
// Photo Path
const photo = fs.readFileSync('Educative-Thumbnail.png');
// Define Query Parameters here
const 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 options
const options = {
method: "POST",
headers: headerParameters,
body: body
};
// Function to make API call
async function postPhotoOnGroup() {
try {
endpointUrl.search = queryParameters;
const response = await fetch(endpointUrl, options);
// Printing response
printResponse(response);
} catch (error) {
// Printing error message
printError(error);
}
}
// Calling function to make API call
postPhotoOnGroup();

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 the fs library.

  • Lines 17–19: We add the access_token in the queryParameters variable.

  • Lines 21–23: We create a FormData and append the caption and photo to it.

  • Line 36: We use the fetch function to make the API call.

Response Fields

Name

Type

Description

id

String

This is the ID of the photo.

created_time

String

This is the time when the photo was created. The time is in ISO 8601 format.

from

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

access_token

String

Mandatory

This is the token that we received in response after making the call to the accounts edge of the `user` object.

group_id

String

Mandatory

This is the group's ID. Note that this is a path parameter.

title

String

Optional

This is the title of the video.

description

String

Optional

This is the description of the video.

video_file

String

Mandatory

This is the binary form of the video file we want to upload on the group.

published

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.

Press + to interact
// Importing libraries here
import fetch from "node-fetch";
import fs from 'fs';
import {FormData, Blob} from "formdata-node"
// Define endpoint URL here
const endpointUrl = new URL("https://graph.facebook.com/v16.0/{{GROUP_ID}}/videos");
const headerParameters = {
contentType: "application/json",
};
// Video Path
const videoFile = fs.readFileSync('Welcome_to_Educative.mp4');
// Define Query Parameters here
const 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 options
const options = {
method: "POST",
headers: headerParameters,
body: body
};
// Function to make API call
async function postVideoOnGroup() {
try {
endpointUrl.search = queryParameters;
const response = await fetch(endpointUrl, options);
// Printing response
printResponse(response);
} catch (error) {
// Printing error message
printError(error);
}
}
// Calling function to make API call
postVideoOnGroup();

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 the fs library.

  • Lines 17–19: We add the access_token in the queryParameters variable.

  • Lines 21–23: We create a FormData and append the description and video_file to it.

  • Line 36: We use the fetch function to make the API call.

Response Fields

Name

Type

Description

id

String

This is the ID of the video.

description

String

This is the description of the video.

from

Object

This is the object containing the ID and name of the user or page that posted the video.

title

String

This is the title of the video.

source

String

This is the video file's URL.

created_time

String

This is the time when the video was created. The time is in ISO 8601 format.

updated_time

String

This is the time when the video was updated. This time is in ISO 8601 format.