如何从我的应用程序中获取Facebook用户ID?
我创建了一个Facebook应用程序,并通过下面的代码向用户发送请求.现在,当用户允许我的应用程序时,我需要他的ID和电子邮件地址进入我的画布URL.但是在下面的代码中,用户不要转到我的画布上画布URL.因此,请帮助我解决,当一个用户允许我的应用程序并且我获得该用户的用户ID时,如何转到我的画布URL?我的代码如下:
I created a facebook application and send request to a user through below code.Now when a user allow my application then i need his id and email address into my canvas url.But on that below code user don't go to my canvas URL.So,Please help me to solve ,how a user go to my canvas url when he allow my application and i get the user id of that user?My code is below:
require_once'facebook.php';
$ facebook = new Facebook(array(
'appId'=>'#######',
'秘密'=>'###################',
'cookie'=> true,));
$ req_perms =发布流,离线访问,用户状态,电子邮件,阅读流";
require_once 'facebook.php';
$facebook = new Facebook(array(
'appId' => '#######',
'secret' => '###################',
'cookie' => true, ));
$req_perms = "publish_stream,offline_access,user_status,email,read_stream";
$ session = $ facebook-> getSession();
$session = $facebook->getSession();
$ loginUrl = $ facebook-> getLoginUrl(array('canvas'=> 1,'fbconnect'=> 0,'req_perms'=> $ req_perms));
$ me = null;
$loginUrl = $facebook->getLoginUrl(array('canvas'=>1,'fbconnect' => 0,'req_perms'=>$req_perms));
$me = null;
如果(!$ session) {echo"top.location.href ='$ loginUrl';";退出;}
if (!$session) { echo "top.location.href= '$loginUrl';";exit;}
其他{
try {
$uid = $facebook->getUser();
$me = $facebook->api('/me');
}
catch (FacebookApiException $e)
{ echo "<script type='text/javascript'>top.location.href= '$loginUrl';</script>"; exit;}
}
所以,请帮助我获取用户ID.
So,please help me to get the user id.
预先感谢
里亚德
Facebook ID&可以通过以下方式访问当前用户的电子邮件:
The Facebook ID & email for the current user can be accessed through:
$me['id'];
$me['email'];
那是你的追随吗?