You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取Facebook主页实时直播流并嵌入教会应用

Hey there! Let's break down how to solve this problem for your church's app—focused solely on grabbing active Facebook Live streams from your church's page, no old videos needed. Here's a step-by-step guide tailored to your needs:

1. Prerequisites First

Before diving into code/API calls, you'll need to set up a few things on Facebook's Developer Platform:

  • Create a Facebook Developer account and register a new app (select the "Business" type since this is for a church page).
  • Request the necessary permissions for your app:
    • pages_show_list: To access your church's Facebook page details.
    • pages_read_engagement: To read page content including live video statuses.
    • pages_read_user_content (if needed): For accessing more detailed live video metadata.
  • Generate a long-lived Page Access Token: Short-lived tokens expire quickly, so convert a short-lived user token to a 60-day user token, then swap that for a permanent Page token (this won't expire unless your church revokes app access).
2. Detect When a Live Stream Starts

You have two reliable ways to know when a live stream goes live—pick the one that fits your app's complexity:

This is the most efficient method (no constant polling) and will notify your app instantly when a live stream starts:

  • In your Facebook app dashboard, navigate to Webhooks > Add Product > Select "Pages" as the subscription object.
  • Set up a public endpoint on your server that can receive HTTP POST requests (Facebook will send a verification request first to confirm this endpoint is valid).
  • Subscribe to the live_video field, specifically the update event. When your church's page starts a live stream, Facebook will send a payload to your endpoint with the live video's ID and status (marked as LIVE).

Option 2: Periodic Polling (Simpler for Small Apps)

If setting up Webhooks feels too heavy, you can periodically check the page for active live streams:

  • Call the Graph API endpoint at regular intervals (e.g., every 1-5 minutes) to fetch only live streams:
    curl -X GET "https://graph.facebook.com/v18.0/{YOUR_CHURCH_PAGE_ID}/live_videos?status=LIVE&access_token={YOUR_PAGE_ACCESS_TOKEN}"
    
  • If the response returns a non-empty data array, that means a live stream is active—grab the id of the live video from the response.
3. Grab the Active Live Stream URL

Once you have the active live video's ID, call the Graph API to get the real-time stream URL:

curl -X GET "https://graph.facebook.com/v18.0/{LIVE_VIDEO_ID}?fields=stream_url&access_token={YOUR_PAGE_ACCESS_TOKEN}"

The stream_url field in the response is an HLS (HTTP Live Streaming) URL that you can embed directly into your church's app using a video player that supports HLS (most modern mobile/web players do).

4. Key Notes & Troubleshooting
  • Stream URL Expiry: The stream_url is temporary and may refresh during a long stream—if your app needs to maintain the stream for hours, consider re-fetching the URL every 30-60 minutes.
  • API Version: Always use the latest Graph API version (e.g., v18.0 at the time of writing) to avoid deprecated endpoints.
  • Permission Checks: If you get empty responses or errors, double-check that your Page access token has all the required permissions and hasn't expired.

内容的提问来源于stack exchange,提问作者Fábio Monteiro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:30:43