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="https://github.com/ThatGuySam/facebook-live-embed-php/raw/master/<?= $FacebookLive->getEmbedAddress() ?>" frameborder="0" allowfullscreen></iframe>
$ git clone https://github.com/ThatGuySam/facebook-live-embed
$ cd facebook-live-embed
$ composer install
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="https://github.com/ThatGuySam/facebook-live-embed-php/raw/master/<?= $FacebookLive->getEmbedAddress() ?>"
scrolling="no"
frameborder="0"
webkitallowfullscreen="1" mozallowfullscreen="1" allowfullscreen="1"
></iframe>
</div>
</div>