I'm trying to use the new Facebook Graph API on my website. This is what I have:
Somewhere on the page:
<fb:login-button autologoutlink="true" perms="email,user_birthday,status_update,publish_stream"></fb:login-button>
Right after the tag:
<div id="fb-root"> </div> <script type="text/javascript"> window.fbAsyncInit = function () { FB.init({ appId: '<%= ConfigurationManager.AppSettings["FBAppId"] %>', status: true, cookie: true, xfbml: true }); /* All the events registered */ FB.Event.subscribe('auth.login', function (response) { // do something with response alert("login success"); }); FB.Event.subscribe('auth.logout', function (response) { // do something with response alert("logout success"); }); FB.getLoginStatus(function (response) { if (response.session) { // logged in and connected user, someone you know alert("login success"); } }); }; (function () { var e = document.createElement('script'); e.type = 'text/javascript'; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; e.async = true; document.getElementById('fb-root').appendChild(e); } ()); </script>
but when I click on the generated login button, nothing happens.
In addition, I'm getting
FB.getLoginStatus() called before calling FB.init().
in Firebug console.
Any ideas?
The method FB. init() is used to initialize and setup the SDK. If you have followed our SDK quickstart guide, you won't need to re-use this method, but you may want to customize the parameters used. All other SDK methods must be called after this one, because they won't exist until you do.
#3: Set Up Facebook Login for Your Website At this point, you'll see Facebook Login among your website app options. Click the Set Up button to get started. Next, you'll fill in the information about how and where you'll use the app. You can add the Facebook Login feature on any app across multiple devices.
In your Facebook app configuration, click on the Settings tab on the left-hand navigation menu. Then go to the Advanced tab at the top and scroll down to the Client OAuth Settings section.
I can't believe it, I was referencing a non existing key in the Web.config hence FB.init was failing silently.
It works as expected now.
To be clearer I wasn't passing the appId to FB.init, once I did, it worked.
Had the same issue, here is the solution that worked for me. Just put the following in your head section or in other words, add the app_id to the source of the facebook js.
<script src="//connect.facebook.net/en_US/all.js&appId=xxxxxxxxxxxxxxx" type="text/javascript"></script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With