简体   繁体   English

如何使用“fblogin”php 自定义 facebook 登录按钮?

[英]How to customize facebook login button using “fblogin” php?

In my website I am using using the facebook login button.在我的网站中,我使用的是 facebook 登录按钮。 By using fblogin its rendering default facebook login button.通过使用 fblogin 其呈现默认 facebook 登录按钮。 But I want to keep my own button instead of default facebook button.但我想保留我自己的按钮而不是默认的 facebook 按钮。 (Am not using javascript sdk). (我没有使用 javascript sdk)。

Can anyone help me?谁能帮我?

If you are using php sdk then you can have your own button with link to the facebook login url如果您使用的是 php sdk,那么您可以拥有自己的按钮,并链接到 facebook 登录 Z572D4E421E5E6B71CE2111

$loginUrl   = $facebook->getLoginUrl() // which will give the login url 

then just link that with the image/button然后只需将其与图像/按钮链接

echo "<a href='$loginurl' style='text-decoration:none'>
<img src='path/to/image' style='border:0;'></a>";

You can use the Javascript SDK to authenticate easily.您可以使用 Javascript SDK 轻松进行身份验证。 You just need to call FB.login from a click event on a dom element.您只需要从 dom 元素上的单击事件调用 FB.login。 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('User: ' + response.name);
            alert('Full details: ' + JSON.stringify(response));
          }
        );
      }
    } , {perms:''}); 
}
</script>
</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM