Gets current or latest live stream from a Facebook page
Based on youtube-live-embed
This generates the embed code for you with respect to width and height of the livestream(ie: Portrait live streams from phones)
<div class="embed-container">
<?= $FacebookLive->embedCode() ?>
</div>
This just get the embed url so you can use it more custom ways
<iframe src="<?= $FacebookLive->getEmbedAddress() ?>" frameborder="0" allowfullscreen></iframe>
$ git clone https://github.com/ThatGuySam/facebook-live-embed
$ cd facebook-live-embed
$ composer install
- Go to https://developers.facebook.com/
- Create a new app and get the App ID and the App Secret
- Get the link for the page you want to pull live streams from
- In the install folder rename config-sample.php to just config.php
- Edit config.php and add your App ID, App Secret, and Facebook Page Link respectively
require_once __DIR__ . '/GetFacebookLiveStream.php';
$FacebookLive = new GetFacebookLiveStream([
'facebook_page' => $fb_page, // Facebook Page URL or ID
'app_id' => FB_APP_ID, // Facebook App ID
'app_secret' => FB_APP_SECRET, // Facebook App Secret
'cache_stream_for' => 60, // How long to cache request for in seconds
]);
This generates the embed code for you with respect to width and height of the livestream(ie: Portrait live streams from phones)
<div class="embed-container">
<?= $FacebookLive->embedCode() ?>
</div>
<div class="fb-live-embed embed-container">
<div class="embed-responsive embed-responsive-16by9 is-<?= $FacebookLive->embed_orientation ?>" style="padding-top: <?= $FacebookLive->embed_ratio_percent; ?>" >
<iframe
src="<?= $FacebookLive->getEmbedAddress() ?>"
scrolling="no"
frameborder="0"
webkitallowfullscreen="1" mozallowfullscreen="1" allowfullscreen="1"
></iframe>
</div>
</div>