How can I get user email and name using Facebook to connect a new platform

I am using facebook connection with the new platform on my asp.net website which is in version 2.0. I want to get the email address and username. How can i do this. Best wishes.

+2
source share
2 answers

Email address and other user information from Facebook, with permission

Before that you must have

Facebook app id and secret id, these values ​​can be created from under the link when you log in to facebook

https://developers.facebook.com/apps

follow the steps to create applications and you will automatically close the keys

enter image description here

Step 0

do test.php and below content

<html> <head> <title>My Facebook Login Page</title> </head> <body> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({ appId : 'YOUR_APP_ID', status : true, cookie : true, xfbml : true, oauth : true, }); }; (function(d){ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_US/all.js"; d.getElementsByTagName('head')[0].appendChild(js); }(document)); </script> <div class="fb-login-button" scope="email,user_checkins"> Login with Facebook </div> </body> </html> 

enter image description here

Step 1

Download Facebook php-sdk from the link below.

https://github.com/facebook/php-sdk update Dec 23, 2012 https://github.com/facebook/facebook-php-sdk

paste it into the working directory and extract it and rename it as facebook-php-sdk

Step 2

https://developers.facebook.com/docs/guides/web/

You can copy the code below from the link above,

or below code, fully functional and perfectly designed to recover email and other information.

  <?php define('YOUR_APP_ID', '99999998558585'); //uses the PHP SDK. Download from https://github.com/facebook/php-sdk require 'facebook-php-sdk/facebook.php'; $facebook = new Facebook(array( 'appId' => '99999998558585', 'secret' => 'h4h23jh4lk23j432j42bdaf', )); $userId = $facebook->getUser(); echo "FB User Id : " . $userId; $userInfo = $facebook->api('/me'); echo "<pre>"; print_r($userInfo); echo "</pre>"; ?> 

and added image for convenience

and the final output will be displayed on the image

enter image description here

+10
source

These two links will help you.

Authentication specifically Authentication of users in a web application section

Advanced Permissions

+1
source

Source: https://habr.com/ru/post/1402203/


All Articles