Facebook Live Stream Static URL - facebook

I was curious as to if there is anyway to have a certain page on Facebook have a static URL for it's Live Streams. I want this so I can use that static URL and embed it on a website (Weebly or Wordpress). Does anyone know of a way to do this?
Any and all input is greatly appreciated.
Thanks much!

No, currently there is no such direct feature provided by Facebook to achieve what you want to do. But there is definitely an indirect way of doing this using Facebook Graph API.
Indirect method of doing so:
Use your page ID to get status of last live video of your page.
/Page_ID?fields=live_videos.limit(1){status}
If you get status field as 'LIVE', it means your video is still LIVE on your page. Then, use the returned Video Id of Live video to make next request.
You can get the embed html of the live video using this request:
/Video_ID?fields=embed_html
Use the returned embed_html to embed live video in your wordpress site.
You just need to write the script that executes the above task and embed video conditionally if the status of video is LIVE otherwise not.

This is a pretty old question, but here's my solution:
Make a GET request to https://facebook.com/PAGE_ID/live
Capture the redirect - this request redirects to the URL you want
How I did it in Node.JS
const https = require("follow-redirects").https;
const PageID = "nexe32"
let redirected = false;
https.get({
host: 'facebook.com',
path: `/${PageID}/live`,
headers: {
"User-Agent": 'curl/7.43.0'
},
beforeRedirect: (opts) => {
if(!redirected) {
redirected = true;
} else {
console.log(opts.href); // the URL you want
redirected = false;
}
}
});
``

Related

How can I handle Media sharing in my PWA app when sharing media from another app into my app?

I am working on a Progressive web app that works on both web version and mobile version. I am sharing media files with others apps but when I share media from another app (Or any other social like Facebook, Messenger, LinkedIn) into my app after selecting my app it just opens up and turns into a black screen. I need help with how I can forward the screen into my share list screen and the data which is shared by another app how can I access them. Any Help?
Double check your method is "POST" and that enctype is present. enctype must be "multipart/form-data", and a files entry must be added in your manifest where you specify your share_target. files is an array that specifies the types of files your app accepts.
more info from: https://web.dev/web-share-target/
The foreground page cannot process this data directly. Since the page sees the data as a request, the page passes it to the service worker, where you can intercept it with a fetch event listener. From here, you can pass the data back to the foreground page using postMessage() or pass it on to the server:
self.addEventListener('fetch', event => {
const url = new URL(event.request.url);
// If this is an incoming POST request for the
// registered "action" URL, respond to it.
if (event.request.method === 'POST' &&
url.pathname === '/bookmark') {
event.respondWith((async () => {
const formData = await event.request.formData();
const link = formData.get('link') || '';
const responseUrl = await saveBookmark(link);
return Response.redirect(responseUrl, 303);
})());
}
});

Facebook profile pic URL redirect to different URL

I am using Faceboook API to login into my website through FB.
In this when I try to fetch the profile photo of the logged-in user through URL "http://graph.facebook.com/100003373201743/picture". Didn't get the response in code.
*id of user fetched from FB # run time.
Found the reason as well, coz defined URL redirects to "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-frc3/t1.0-1/p50x50/1975108_483512481771188_559759638979699650_s.jpg". I am not finding any link between these two URLs. So that I can directly hit to redirected one URL.
You can directly use the image url as "http://graph.facebook.com/100003373201743/picture", as #Tobi has mentioned
or,
if you want to fetch the actual url, you can get that in response of this-
http://graph.facebook.com/100003373201743/picture?redirect=0
You'll get the response as-
{
data: {
url: "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-frc3/t1.0-1/p50x50/1975108_483512481771188_559759638979699650_s.jpg",
is_silhouette: false
}
}
I found the solution of this problem.
Fetching headers of the URL "http://graph.facebook.com/100003373201743/picture".
Header named as "Location" have the value of redirected URL like "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-frc3/t1.0-1/p50x50/1975108_483512481771188_559759638979699650_s.jpg"
So hitting this URL and its working fine.

when used /me/feed post, it seems that the facebook is using cached link url

I have made an web site using facebook api.
such as below
var params = {
method : "stream.publish",
message : $("#textareaForSns").val(),
picture : urlForGameIcon,
name : titleForSns,
description : descriptionForSns,
link : "http://hgurl.me/a5t"
};
FB.api("/me/feed", "post", params ...
but, I found a problem. :(
I used link url as http://hgurl.me/a5t. this url is operating to redirect to another web site according to device type. (mobile or pc)
I changed redirection url later but it doesn't redirect to new url in each post. it occasionally redirect to old url yet
old one is 183.110.213.149:10080/ds/install.php.
new one is drgfriends.hangame.com
I don't know exactly how the facebook is working internally. I think that facebook is using cache data.
how can I make this short url working to redirect to new url I changed?
can I remove the cache?
please help me sir
thank you

How to detect if is the user the fan of my page

I have a little problem, I don't know how to create the script (with PHP SDK) which check if is the user a fan of my page.
I successfly get the permission for user_likes, but I cant post data to array and after check it.
When I dump this code: $user_likes = $facebook->api('/me/likes'); I'll got all data, but I cant post them to array.
It's amazing what one can find on the internet these days if only he tries to Google his questions...
Here's the first result I got for "facebook is the user a fan":
http://www.masteringapi.com/tutorials/facebook-api-check-if-a-user-is-fan-of-a-facebook-page/20/
It discuss a few options, PHP and JavaScript, Graph API and REST API, just pick your favorite.
FB.api("me/likes/270801249647033", function(response) {
if ( response.data.length == 1 ) {
// Has liked
} else {
// Not liked
}});
Source and download script
From: http://developers.facebook.com/docs/reference/rest/pages.isFan/ (yes, this is deprecated, but it includes the new Graph API way to do things at the top of it. :) )
You can now issue a HTTP GET request to /USER_ID/likes/PAGE_ID (aka /me/likes/PAGE_ID ) to check if a user is a page of a fan.

Facebook standard status update popup?

Is there an API for opening a popup containing the same status update functionality as in the Facebook Wall?
I basically want to open the following UI in a popup...
How can I do that?
You have to mention the onclick function else what suits your need. oauth2 in facebook involves two steps, call authorize to get code, then call access_token to get token. One way to deal with the pop login:
open login url in new window just like you did,when the facebook redirects back to your url in the popup, you set the cookie either through server side code or using javascript to capture url query parameter, when page is loaded in the popup, close the window immediately window.close.
On your main page, after your window.open code, add JavaScript code to detect if popup is closed and capture the cookie:
var signinWin;
`$('#FacebookBtn').click(function () {
var pos = screenCenterPos(800, 500);
signinWin = window.open("[URL]", "SignIn", "width=780,height=410,toolbar=0,scrollbars=0,status=0,resizable=0,location=0,menuBar=0,left=" + pos.x + ",top=" + pos.y);
setTimeout(CheckLoginStatus, 2000);
signinWin.focus();
return false;
});
function CheckLoginStatus() {
if (signinWin.closed) {
$('#UserInfo').text($.cookie("some_cookie");
}
else setTimeout(CheckLoginStatus, 1000);
}`
hope it help you.
The facebook UI responsible to post a feed is described here.
If you want to have the same design in your application you have to design it yourself, which would be easy with jQuery + ajax