我如何可以通过Facebook连接新平台来获取用户电子邮件和名称 [英] How i can get user email and name with Facebook connect new platform
问题描述
我正在使用2.0网站的asp.net网站上的Facebook连接新平台。我想得到用户的电子邮件和名称。我怎么能这样做
来自Facebook的用户的电子邮件地址和其他信息,用户权限
在此之前,您应该有
Facebook应用ID和密码,这些值可以从以下链接创建,当您登录到Facebook
update 23 dec 2012
https:/ /github.com/facebook/facebook-php-sdk
将其粘贴到工作目录中,并将其解压缩并重命名为 php-sdk
步骤2
https://developers.facebook.com/docs/guides/web/
您可以从上面的链接复制以下代码,
或以下代码完全功能,完美地用于删除电子邮件和其他信息
<?php
define('YOUR_APP_ID','99999998558585');
//使用PHP SDK。从https://github.com/facebook/php-sdk
下载请求'facebook-php-sdk / facebook.php';
$ facebook = new Facebook(array(
'appId'=>'99999998558585',
'secret'=>'h4h23jh4lk23j432j42bdaf',
)) ;
$ userId = $ facebook-> getUser();
echoFB User Id:。 $用户id;
$ userInfo = $ facebook-> api('/ me');
echo< pre>;
print_r($ userInfo);
echo< / pre>;
?>
并为易于添加的图像
和最终输出将显示在图像中
i am using facebook connect with new platform in my asp.net web site which is in 2.0. i want to get user email and name. how i can do that. Regards.
Email address and other information of user from Facebook, with users permission
Before this you should have
Facebook app id and secret id , these values can be created from below link, when you are logged into facebook
https://developers.facebook.com/apps
follow steps to create apps and you will keys automatically
Step 0
make a test.php and below contents
<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>
Step 1
Download Facebook php-sdk from below link
https://github.com/facebook/php-sdk update 23 dec 2012 https://github.com/facebook/facebook-php-sdk
paste it your working directory and extract and rename it as facebook-php-sdk
Step 2
https://developers.facebook.com/docs/guides/web/
you can copy below code from above link,
or below code fully functional and perfectly made for retriving 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 easibility
and final output will be displayed in image
这篇关于我如何可以通过Facebook连接新平台来获取用户电子邮件和名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!