這份文件已更新。
中文(台灣) 的翻譯尚未完成。
英文更新時間:5月21日
中文(台灣) 更新時間:2022年9月13日

Getting Started

This document explains how to use the Live Video API to broadcast a live video broadcast with your app. If you do not have an app, you can use the Graph API Explorer and streaming software of your choice.

Meta 將在 2024 年 6 月 10 日推出新的必備條件,帳號必須符合這些必備條件才能在 Facebook 上直播。新的必備條件如下:

  • Facebook 帳號必須已使用至少 60 天
  • Facebook 粉絲專頁或個人檔案專業模式必須擁有至少 100 位追蹤者

Before You Start

If you have an app, you will need the following:

If you don't have an app, you also will need:

Start the broadcast

To create a LiveVideo object, send a POST request to the /me/live_videos?status=LIVE_NOW endpoint where me is the ID for the User or Page.

When testing an API call, you can include the access_token parameter set to your access token. However, when making secure calls from your app, use the access token class.

curl -i -X POST \
 "https://graph.facebook.com/v20.0/me/live_videos?status=LIVE_NOW"

This will return a response that looks like this:

{ 
  "id": "10214937378883406",  //The LiveVideo object ID
  "stream_url": "rtmp://rtmp-api.faceboo...",
  "secure_stream_url": "rtmps://rtmp-api.faceboo...", //The stream URL
  "stream_secondary_urls": [],
  "secure_stream_secondary_urls": []
}

Capture the id and secure_stream_url values that were returned to you. The id is the LiveVideo object ID which you can use to manipulate your broadcast. The secure_stream_url is the ingest URL that you will use to stream live video data from your encoder to the LiveVideo object.

Stream the broadcast

Pass the secure_stream_url value that you captured in the last step to your encoding device and stream live video data to it. Once the LiveVideo object detects streaming data, the broadcast will go live on your User profile.

View your profile and verify that a new live video post has been created and is broadcasting your streaming data.

If you are using streaming software instead of developing your own app, manually add the secure_stream_url value to your software. Depending on which streaming software you are using, you may have to break the stream URL into its server (rtmps://rtmp-api.facebook.com/rtmp/) and key components (everything after /rtmp/).

End the broadcast

To end the broadcast, send a POST request to the /<LIVE_VIDEO_ID>?end_live_video=true endpoint.

Example end broadcast request

curl -i -X POST \
  "https://graph.facebook.com/v20.0/<LIVE_VIDEO_ID>?end_live_video=true"

This ends your broadcast and saves it as a video on demand (VOD). If you want to delete the VOD, send a request to the DELETE /<LIVE_VIDEO_ID> endpoint.

Permission denied error codes

CodeSubcodeMessageTypeMitigation messaging

200

1363120

Permissions error

OAuthException

You’re not eligible to go live

Your profile needs to be at least 60 days old before you can go live on Facebook. Learn more at https://www.facebook.com/business/help/167417030499767?id=1123223941353904

200

1363144

Permissions error

OAuthException

You’re not eligible to go live

You need at least 100 followers before you can go live from your profile. Learn more at https://www.facebook.com/business/help/167417030499767?id=1123223941353904

Next Steps