Is there a way or a link to a static image url to display the Facebook "Login with Facebook" button instead of the "Connect with Facebook" button? This seems to be the only link I can find for Connect with Facebook. I am able to generate a "Login with Facebook" button using FBML markup fb:login_button but in this case, I'm generating a login url link (in order to direct user through to a touch-enabled Facebook login interface -display=touch).
Facebook – Display a static Facebook login button image without using FBML
Related Solutions
Actualy, there's a better solution.
There are 2 things that you could do better:
- In your
FB.init
method, you're settingstatus: true
. This tells the page that it should check whether the user is logged in the facebook immediately after page loads. In your case, it's not only that you don't need it - it will take some of your visitor's bandwidth for round trip to facebook that you don't actually need. - You don't need to remember uid and accessToken variables since you can get them on demand by using
FB.getLoginStatus
method.
The complete solution based on your sample code would be:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : 'YOUR APP ID',
status : false,
cookie : true,
xfbml : true
});
};
(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));
function Facebook_login () {
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var uid = response.authResponse.userID;
var accessToken = response.authResponse.accessToken;
if ((parseFloat(uid) == parseInt(uid)) && !isNaN(uid)) {
$.ajax({
url: '/user_actions/prep_facebook_registration',
cache: false,
type: 'POST',
data: { 'uid': uid, 'token': accessToken },
dataType: 'json',
success: function(data) {
if (data.success=='true') {
if ((typeof(data.redirect) != 'undefined')) {
if (data.redirect=='current') {
location.reload();
} else {
window.location=data.redirect;
}
}
}
}
});
}
}
}
}
</script>
<div class="fb-login-button" onlogin="Facebook_login()" autologoutlink="true" [parameters]></div>
You can get the official "Log in with Facebook" button here. ZIP has PNGs for different sizes https://developers.facebook.com/docs/facebook-login/checklist/#brandedlogin
EDIT 26/07/2014: Facebook seems to have removed those image assets. They now suggest you using a Javascript log in button with their button style. https://developers.facebook.com/docs/plugins/login-button
EDIT 21/02/2018: Facebook has updated the guidelines with a new "Continue on Facebook" button image asset
Best Answer
I found this image set very useful.
social buttons as images