Broadcast on a User Feed and Page
Discover how to broadcast live videos on user feeds and Facebook pages using Facebook Graph API. Learn to create live videos via API requests, manage permissions with access tokens, and handle streaming details to go live effectively.
We'll cover the following...
Broadcast on a user feed
To broadcast live on a user's feed, we first need to create a live video by making a POST request to the /user_id/live_videos endpoint with the user access token that has the publish_video permission and relevant parameters. Once the live video is created, we will receive a stream_url and a stream_key that we can use to stream the video to Facebook. The base URL for this endpoint is:
https://graph.facebook.com/v16.0/{user_id}/live_videos
Request parameters
The following are the request parameters for the above endpoint.
Parameter | Type | Category | Description |
| String | Mandatory | This is the token that we received after app authentication and authorization. |
| String | Mandatory | This is the ID of the user. Note that this is a path parameter. |
| String | Optional | This is the title of the live video. |
| String | Optional | This is the description of the live video. |
| Boolean | Optional | This indicates whether a recording of the live video should be saved for later viewing. |
| Boolean | Optional | This indicates whether the live video should be published immediately or be saved as a draft. |
| String | Optional | This is the status of the live video; it can be either |
| DateTime | Optional | This is the date and time when the live video will be broadcast; it is in ISO 8601 format. |
| Boolean | Optional | This indicates whether the live video should be audio-only. |
| Array | Optional | This is the array of RTMP URLs that we can use to stream to the live video. |
| String | Optional | These are the encoding settings for the live video. |
The code below uses the endpoint above to create a live video. Click the “Run” button to see the response.
In the code widget above:
Line 5: We define the endpoint URL in the
endpointUrlvariable.Lines 18–23: We add the
access_token, specify thetitleanddescription, and set thestatustoLIVE_NOWto specify the state of a live video in thequeryParametersvariable.Line 29: We use the
fetchfunction to make the API call.
Response fields
The following are the response fields for the above endpoint.
Name | Type | Description |
| String | This is the ID of the live video. |
| String | This is the current status of the live video; it can be either |
| String | This is the title of the live video. |
| String | This is the URL of the live video's stream. |
| String | This is the secure URL of the live video's stream. |
| String | This is the URL of the live video on Facebook. |
| Boolean | This indicates whether the live video has been published or not. |
| DateTime | This is the time the live video was created. The time is in ISO 8601 format. |
| DateTime | This is the time the live video was updated. The time is in ISO 8601 format. |
| String | This is the HTML code to embed the live video on another website. |
| DateTime | This is the time when the live video was started. The time is in ISO 8601 format. |
| DateTime | This is the time when the live video was ended. The time is in ISO 8601 format. |
Note: We can use the same
live_videosedge with our page ID and group ID to start broadcasting on pages and groups, respectively. To broadcast on a page, we will use a page access token instead of a user access token.