Reputation: 11
I want to get Video source URL with Graph API by using Javascript SDK
This is what i have built using default code for video object
function getVideo(id) {
var vid = id;
FB.api(
"video/{vid}",
function (response) {
if (response && !response.error) {
var v = "source": source;
alert(v);
}
}
);
}
Upvotes: 0
Views: 8323
Reputation: 1599
you can request one more extra field param by API
$pageid = "YOURPAGENAME";
$facebook->api("/" . $pageid . "/feed?fields=location&locale=en_GB&fields=type,message,id,story,link,created_time,attachments,source,name,picture,object_id,place&limit=20");
source => will return url mp4 video post
And make sure you will see the type in attachment array,
[type] => video_inline / video_share_youtube
you will get both type of video url like:
https://video.xx.fbcdn.net/v/t42.1790-2/xxxxxxx8431328184267440128_n.mp4
https://www.youtube.com/embed/xxxxxxxxxx?autoplay=1
Upvotes: 0
Reputation: 31479
You need to use the endpoint
/{video_id}
instead of
/video/{video_id}
This is clearly stated in the docs at https://developers.facebook.com/docs/graph-api/reference/v2.1/video/
You code needs to be
function getVideo(id) {
FB.api("/"+id, function (response) {
if (response && !response.error) {
alert(response);
}
});
}
Upvotes: 2