Facebook App using only Javascript SDK without any PHP

Hi, I want to show a facebook login button on my blog using Facebook App.

If the user is logged in facebook,
His/Her photo will be shown on a <img id=“FB_image” /> element
and user can post message on facebook wall using a button with id=“FB_post_msg”

Else (i.e. if the user is not logged in)
A login button will appear on my web.

I have added my blog url in facebook app under Website with Facebook Login option as http://dibyendu-home.blogspot.com

and also added the following code to my blog to authenticate the facebook app and just to check whether it is working or not…

<div id=‘fb-root’/>
<script>
// Additional JS functions here
window.fbAsyncInit = function() {
FB.init({
appId : ‘111111111111’, // Original App ID is not given here
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});

// Additional init code here
FB.getLoginStatus(function(response) {
if (response.status === ‘connected’) {
alert(‘connected’);
} else if (response.status === ‘not_authorized’) {
alert(‘not authorized’);
login();
} else {
alert(‘not logged in’);
login();
}
});
};

};

// Load the SDK Asynchronously
(function(d){
var js, id = ‘facebook-jssdk’, ref = d.getElementsByTagName(‘script’)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(‘script’); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>

But the problem is that it is not showing anything…
I don’t know whether I am doing in the right way or not…
Anyone pls help me out…
If possible please provide instructions to do it…

_

Hey Rani,

There are 2 tiny errors in your code that are preventing it from running. The reason nothing happens is because these errors stop the JavaScript code from executing.

You have an extra closing brace right before the comment “// Load the SDK Asynchronously” and inside that piece of code that loads the SDK, the url to the facebook All.js is surrounded by “"” instead of actual quotes.

I’ve highlighted the issues for you below:


// Additional JS functions here
window.fbAsyncInit = function() {
    FB.init({
        appId : '111111111111', // Original App ID is not given here
        status : true, // check login status
        cookie : true, // enable cookies to allow the server to access the session
        xfbml : true // parse XFBML
    });




    // Additional init code here
    FB.getLoginStatus(function(response) {
        if (response.status === 'connected') {
            alert('connected');
        } else if (response.status === 'not_authorized') {
            alert('not authorized');
            login();
        } else {
            alert('not logged in');
            login();
        }
    });
};


[COLOR=#ff0000]}; // << This is an extra brace[/COLOR]


// Load the SDK Asynchronously
(function(d){
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement('script'); js.id = id; js.async = true;
[COLOR=#ff0000]    js.src = &quot;//connect.facebook.net/en_US/all.js&quot;; // << These &quot; should be "[/COLOR]
    ref.parentNode.insertBefore(js, ref);
}(document));
</script>