简体   繁体   中英

Facebook Login Button - Can I get Facebook to tell the user what info my app is getting?

I used this guide from CodexWorld to create a facebook login button for my app https://www.codexworld.com/login-with-facebook-using-php/

It goes to a facebook login page that looks like this: http://puu.sh/xdxmv.png which is good, but we also want this page to show them what information Facebook is giving to our app. Looking for something like this: http://puu.sh/xdxy8.jpg . Is there a way do add that to this method of logging in?

The code that I think generates the button and tells it where to redirect:

$redirectURL   = 'http://myapp.com'; // Callback URL
$fbPermissions = array('email'); // Optional permissions
$helper = $fb->getRedirectLoginHelper(); // Get redirect login helper
$loginURL = $helper->getLoginUrl($redirectURL, $fbPermissions); // Get login url

echo '<a href="'.htmlspecialchars($loginURL).'"><img style="margin-top: 10px;" src="assets/fblogin-btn.png"></a>'; // render the button

Thanks

Please try the following code:

<?php
   session_start(); 
?>
<html xmlns:fb = "http://www.facebook.com/2008/fbml">
   
   <head>
      <title>How To Login With Facebook In Php With Example - Phpcodingstuff.com</title>
      <link 
         href = "http://www.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel = "stylesheet">
   </head>
   
   <body>
      <?php if ($_SESSION['FBID']): ?>      <!--  After user login  -->
         
         <div class = "container">
            
            <div class = "hero-unit">
               <h1>Hello <?php echo $_SESSION['USERNAME']; ?></h1>
               <p>Welcome to "facebook login" tutorial phpcodingstuff.com</p>
            </div>
            
            <div class = "span4">
                
               <ul class = "nav nav-list">
                  <li class = "nav-header"><img src="https://i.imgur.com/76Chgd4.png"></li>
                        
                  <li><img src = "https://graph.facebook.com/<?php 
                     echo $_SESSION['FBID']; ?>/picture"></li>
                  
                  <li class = "nav-header">Facebook ID</li>
                  <li><?php echo  $_SESSION['FBID']; ?></li>
               
                  <li class = "nav-header">Facebook fullname</li>
                        
                  <li><?php echo $_SESSION['FULLNAME']; ?></li>
               
                  <li class = "nav-header">Facebook Email</li>
                        
                  <li><?php echo $_SESSION['EMAIL']; ?></li>
               
                  <div><a href="logout.php">Logout</a></div>
                        
               </ul>
                    
            </div>
         </div>
         
         <?php else: ?>     <!-- Before login --> 
         
         <div class = "container">
            <h1>Login with Facebook</h1>
                      
            <div>
               <a href = "fbconfig.php"><img src="https://www.phpcodingstuff.com/uploads/tutorial_images/how_to_login_facebook_login_in_php.png"></a>
            </div>
         </div>
         
      <?php endif ?>
      
   </body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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