Facebook SDK: Replace “Log In” button with custom image

北慕城南 提交于 2019-11-28 12:37:21

问题


I have Page Tab App, which has a landing page with a "Log In" button for users to click to install the App. Can I replace the "Log In" button with my custom image?

The current code for the "Log In" button is :

<div class="fb-login-button" data-scope="friend_likes"></div>

回答1:


You can use the JS Api for this,

function fbAuth() {
    FB.login(function(response) {
      if (response.authResponse) {
        alert('User fully authorize the app.');
      } else {
        alert('User canceled login or did not fully authorize the app.');
      }
    }, { scope: 'friend_likes' });
}

then you can call it in a custom button with the onclick event:

<a href="#" onclick="return fbAuth();">Login</a>

Facebook Documentation: FB.login



来源:https://stackoverflow.com/questions/9952611/facebook-sdk-replace-log-in-button-with-custom-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!