I am trying to implement my Facebook share button in my modal window with AngularJS. The share button shows the first time when I refresh the page, but the button is gone after I change my route to somewhere else and back to the modal window route page. How keep the Facebook button?
Here is my code:
<!--under my modal window <div>-->
<div class="fb-share-button" data-href='http://goose-dev.elasticbeanstalk.com/gameInfo/{{gameId}}'></div>
<!--outside the modal window -->
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'API KEY',
xfbml : true,
version : 'v2.4'
});
};
(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>
Related
I have problem with adding a chat to the website. The code below works on one page, but doesn't work on another. The domain is added to the whitelist. Does anyone have any idea why this could happen?
Load Facebook SDK for JavaScript -->
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
xfbml : true,
version : 'v4.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/pl_PL/sdk/xfbml.customerchat.js';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<!-- Your customer chat code -->
<div class="fb-customerchat"
attribution=setup_tool
page_id="********"
theme_color="#000000"
logged_in_greeting="Lorem Ipsum"
logged_out_greeting="Lorem Ipsum"></div>
i have added join group fb plugin to my webpage, now i want to trigger a event when someone click on that "join group button".
FB.Event.subcribe is not working for this. i think that's only for like button
window.fbAsyncInit = function() {
FB.init({
appId : '*********',
xfbml : true,
version : 'v3.3'
});
FB.Event.subscribe('edge.create', function(response) {
alert("working");
});
};
(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'));
//code which I get from facebook
<div class="fb-group" data-href="https://www.facebook.com/groups/[group-id]/" data-width="450" data-show-social-context="true" data-show-metadata="false"></div>
I have included the code i needed to be able to show the facebook login button on my page. But the button does not show up, could you please read my code and tell me if you see any problems with it? Thank you
<!DOCTYPE html>
<html>
<body>
<script>
window.fbAsyncInit = function() {
FB.init({
vappId : '486506335043368',
autoLogAppEvents : true,
xfbml : true,
version : 'v2.10'
});
FB.AppEvents.logPageView();
};
(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 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.10&appId=486506335043368";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-login-button" data-max-rows="1" data-size="large" data- button-type="continue_with" data-show-faces="false" data-auto-logout- link="false" data-use-continue-as="false"></div>
</body>
</html>
I think there are 2 possible problems:
1)You need to change js.src assignment to: js.src="https://connect.facebook.net/en_US/all.js";
2)I think Facebook does not support calls from a local file, the script has to be run on a file with an http:// or https:// URI.
See this answer.
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.
I am making a game for facebook, and i want them to be able to login and then go in the game.
I have the login button with the popup screen and permissions i need from them, but i cant get them to redirect back to my url.
i use this code :
<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/nl_NL/all.js#xfbml=1&appId=380841622050947";
fjs.parentNode.insertBefore(js, fjs);
window.navigate("www.google.com");
}(document, 'script', 'facebook-jssdk')); </script>
<div class="fb-login-button" data-max-rows="5" data-size="xlarge" data-show-faces="true" data-auto-logout-link="false" scope="email,publish_stream"></div>
What am i missing?
i tried using this :
window.navigate(”top.jsp”);
But i cant seem to catch the "player logged in" action, so i can redirect after that.
Thanks in advance!!
If you want to redirect the user after successful login, you can use FB.Event.subscribe-
Complete code would be-
<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/nl_NL/all.js#xfbml=1&appId=380841622050947";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
window.fbAsyncInit = function() {
FB.init({
appId : '380841622050947',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.Event.subscribe('auth.login', function(r){
console.log(r.status);
if ( r.status === 'connected'){
window.location.href = '{redirect-to-url}'
}
});
};
</script>
<div class="fb-login-button" data-max-rows="5" data-size="xlarge" data-show-faces="true" data-auto-logout-link="false" scope="email,publish_stream"></div>
Well, it seems that you're not using the complete code necessary to be able to login via JS SDK. Have a look at the guide under https://developers.facebook.com/docs/facebook-login/login-flow-for-web