问题描述:

How do we create a link to initiate the FB connect process WITHOUT using one of their built in button forms <fb:login-button ></fb:login-button>

网友答案:

Just add an onclick event to any of your custom buttons and have it call the FB.login event in their javascript sdk.

Full example:

<!DOCTYPE html>
<html>
<body>
<div id="fb-root"></div>
<a href="#" onclick="doLogin();return false;">Custom Login Button</a>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({ appId: '**yourAppId**', status: true, cookie: true, xfbml : true });

  function doLogin() {  
    FB.login(function(response) {
      if (response.session) {
        FB.api('/me',  function(response) {
            alert('Welcome ' + response.name);
            alert('Full details: ' + JSON.stringify(response));
          }
        );
      }
    } , {perms:''}); 
}
</script>
</body>
</html>
相关阅读:
Top