Videos on a Page
Learn how to upload videos and then fetch uploaded videos on a page.
We'll cover the following...
Videos
The base URL for this endpoint is:
https://graph.facebook.com/v16.0/{page_id}/videos
Request parameters
The request parameters for the above endpoint are given below.
Parameter | Type | Category | Description |
| String | Mandatory | This is the token that we received in response after making the call to the |
| String | Optional | These are the fields we want in the response from the API call. |
| String | Mandatory | This is the page'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 video file. This can be either a file path or a binary file. |
To publish a new video on the page using the Facebook Graph API, we can make a POST request to the video edge of the page object using the page's ID and a page access token that has the publish_video permission. The code below uses the endpoint above to publish a new video on the page. Click the “Run” button to see the response.
In the code widget above:
Line 7: We define the endpoint URL in the
endpointUrlvariable.Line 14: We read the video file using the
readFileSyncfunction of thefslibrary.Lines 17–19: We add the
access_tokenin thequeryParametersvariable.Lines 21–23: We create a
FormDataand append thedescriptionandvideo_fileto it.Line 36: We use the
fetchfunction to make the API call.
Response fields
The response fields for the above endpoint are given below.
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 the video was created. The time is in ISO 8601 format. |
| String | This is the time the video was updated. The time is in ISO 8601 format. |
Note: To get videos uploaded on a page, remove the
bodyand change the method toGETin theoptionsvariable.