trigger 'This video can't be embedded.' facebook video - javascript

I try to trigger an facebook video error in javascript , I have this error in the player ( 'Unavailable
This video can't be embedded.' )
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId: 'XXXXXXXXXX',
xfbml: true,
version: 'v2.5'
});
// Get Embedded Video Player API Instance
var my_video_player;
FB.Event.subscribe('xfbml.ready', function(msg) {
if(msg.type === 'video') {
my_video_player = msg.instance;
}
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if(d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div
class="fb-video"
data-href="https://www.facebook.com/businessinsider/videos/10153852489789071/"
data-width="500"
data-allowfullscreen="true"></div>
How can I trigger when a video can't be play ?

In your facebook app dashboard, go to App review and make it public.

Related

Facebook Javascript API fan_count

I am new to Javascript and am try to follow the Facebook steps to display fan_count (likes) on my webpage. I have done the following but for the life of me can't work out how the count is displayed.
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '231179987472162',
autoLogAppEvents : true,
xfbml : true,
version : 'v3.0'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<h1>Hello, world!</h1>
<script>
FB.api(
'/cityviewshopping',
'GET',
{"fields":"fan_count"},
function(response) {
// Insert your code here
}
);
</script>

facebook follow and like api subscription event code (edge.create not working)

I've implemented liking a website url along with attaching the edge.create event to it. I implemented the follow button but did not get the edge.create to function when clicking to follow button. Also, I cannot figure out how to like a specific facebook page and as well get the edge.create event to subscribe.
I have the following code for when a user performs a LIKE on our website (not the facebook page):
This code works well
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxx',
autoLogAppEvents : true,
xfbml : true,
version : 'v2.9'
});
FB.AppEvents.logPageView();
FB.Event.subscribe('edge.create', function(response) {
alert(1);
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
<div class="fb-like" data-href="https://www.facebook.com/fbpage" data-layout="standard" data-action="like" data-show-faces="true"/>
}
Here is my code for following a facebook page , which works but does not fire the edge.create code
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxx',
autoLogAppEvents : true,
xfbml : true,
version : 'v2.9'
});
FB.AppEvents.logPageView();
FB.Event.subscribe('edge.create', function(response) {
alert(1);
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
<div class="fb-follow" data-href="https://www.facebook.com/fbpage" data-layout="standard" data-size="small" data-show-faces="true"/>
As you can see, I need help getting the edge.create to function with clicking follow button and if possible a way to like a specific facebook page along with the edge.create event code.

OnClick FB.ui not consistently executing

I have this script to get users to share my website in return for a coupon code to use in the shop.
I'm sure it was working fine. Now on some pages it wont execute until the page is refreshed.
It may not even be a script issue but I can't work it out.
Any ideas?
Here is my code.
<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>
<div id="fb-root"></div>
<script type="text/javascript">
$(document).ready(function() {
window.fbAsyncInit = function() {
FB.init({
appId : 'XXXXXX',
xfbml : true,
version : 'v2.5'
});
$('#ShareForcouponcode').on('click',function(e) {
e.preventDefault();
FB.ui(
{
method: 'feed',
name: 'XXX',
link: 'XXX'
},
function(response) {
if (response && response.post_id) {
// the download link will be activated
$('#ShareForcouponcode').fadeOut();
$('#infotext').fadeOut();
$('#couponcode').fadeIn();
} else {
// do nothing or ask the user to share it
}
}
);
});
};
});
// Load the SDK
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

Download Facebook JS SDK

In order to speedup page loading I would like to download Facebook SDK.
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5&appId=1187326234648590";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-share-button" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button_count"></div>
How I Can download the complete library and use it from JavaScript source file?
(function() {
"use strict";
var URLS = {
facebookInit: "//connect.facebook.net/en_US/sdk.js"
};
myApp.initializeFbSdk = function(appId, version) {
$.getScript(URLS.facebookInit, function() {
FB.init({
appId: appId,
version: version
});
});
};
myApp.createFbSharePopup = function(url) {
FB.ui({
method: "share",
href: url
});
};
// other methods if needed
})();
$(document).ready(function() {
myApp.initializeFbSdk(fbAppId, fbSdkVersion);
//...
myApp.createFbSharePopup("www.mysite.org");
});

FB.getLoginStatus() called before calling FB.init(). CRAZY

window.fbAsyncInit = function(){
FB.init({
appID : 'my app id is here',
channelUrl : '//myappname.herokuapp.com/channel.php',
status : true,
cookie : true,
xfbml : true,
frictionlessRequests: true
});
// Additional auth
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
Ok so, that's my scripts.js file, and I HAVE included fb-root to my pagebody, for some reason when loading the page, its logging:
FB.getLoginStatus() called before calling FB.init().
Twice, in the call to all.js line 52, any ideas whats going on?
This is how i make it:
window.fbAsyncInit = function () {
if (FB.init) return;
// init the FB JS SDK
FB.init({
appId: 'your app ID', // App ID from the App
//channelUrl: '//' + window.location.hostname + '/channel.html',
//This to get the user details back from Facebook
//scope: 'id,name,gender,user_birthday,email', etc
status: true, // check the login status upon init?
cookie: true, // set sessions cookies to allow your server to access the session?
xfbml: true // parse XFBML tags on this page?
});
}
At the end of HTML Body...
<script>
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
</script>
...Or maybe you might use fb embeded iframe
Facebook Like Button Reference

Categories

Resources