Reputation: 1
TLDR:- JS amateur here. Call to Graph API, FB.INIT() did not work from my local machine. But worked from my Github static website. Why?
Detail: I am learning (or trying to learn) web app development on my own, after going thru some tutorials thought of creating webpage with JS which calls FB graph API.
Copied FB provided code to load SDK and logic to show like buttons.
Nothing happened when i opened HTML thru browser, but when I pushed it on GitHub it worked! Not sure why?
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxxx',
xfbml : true,
version : 'v2.6'
});
};
(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>
-----------------------------------------
**Code to show like/share buttons:-**
<div
class="fb-like"
data-share="true"
data-width="45"
data-show-faces="true">
</div>
_____________________________________-
Thank you for taking time reading thru this.
Upvotes: 0
Views: 180
Reputation: 22905
It is because the url that you have specified for you Facebook app as callback url is that of github. You can change it for a while and test and see, it will work for "localhost" but not for "127.0.0.1".
Or you can create two apps.
Upvotes: 1