I read this post again and again, and yet it does not make sense to me.
What I'm trying to do is get the email address of a Facebook user so that I can store it in a string and compare to find out if it matches the addresses of existing users in my MySQL database. I only need to do this when the user first grants access rights to the application.
In the "Verified referrals" section of my application developer interface, I set "Permissions for users and friends" to enable "email."
In the canvas area of my site, I have this code:
include('facebook/base_facebook.php'); include('facebook/facebook.php'); $facebook = new Facebook(array( 'appId' => "XXXXXXXXXXXXXXX", 'secret' => "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", )); $user = $facebook->getUser(); if ($user) { try { $user_profile = $facebook->api('/me'); } catch (FacebookApiException $e) { $user = null; } }
If I var_dup () $ user, I can see the user ID (albeit a little more), which seems to be correct, so I believe that I am connecting to the right place on Facebook.
But then there was this suggested line of code , which means that it returns the email address, but when I repeat it to see how it looks, it does not return the email address:
echo "<br/>" . $facebook->getLoginUrl(array('req_perms' => 'email'));
I thought that this was not so, because it is not quite right for me, but, on the other hand, I just have no idea what else to do with this or where to put it.
And then I also came across this post which has code mixed with HTML in a way that puzzles me even more.
Assuming my user allowed my application to see their email, is there an easy way to get it? Something like an inexperienced programmer like me can understand?