How to get email address in FB connect? - facebook

Can we get email address using: users.getStandardinfo?
Please help me on this.
Thank you

You can't. But you can ask the user to provide it when he/she logs in.
There is proxied_email that can be taken from user table, you can try:
$personArray = $facebook->api_client->users_getInfo( $fb_config->user_id, "last_name, first_name, birthday, hometown_location, current_location, is_app_user, proxied_email" );
$email = $personArray[0]['proxied_email'];
if(empty($email)){
echo 'Proxied email was not retreived. Trying fql query...';
$facebookFQLResultXml = $facebook->api_client->fql_query("SELECT proxied_email FROM user WHERE uid=".$fb_config->user_id);
$email = $facebookFQLResultXml['proxied_email'];
}
But I am not sure for the result
So you can get the proxied email and contact the user through it but you
can't extract the original email:
proxied_email - A proxied wrapper alternative for contacting the user through email,
instead of directly calling notifications.sendEmail. If the user shared his or her proxied
email address with you, this address also appears in the email field (see below).
http://developers.facebook.com/docs/reference/rest/users.getInfo

Related

Getting a CloudKit User's (Real) Email Address

I know I can look up a CloudKit user's unique ID like this:
CKContainer.default().fetchUserRecordID() { recordID, error in
if let recordID = recordID{
print(recordID.recordName) //_abcdef1234...
}
}
And then I can ask them for permission to grant access to their contact info like this:
CKContainer.default().requestApplicationPermission(.userDiscoverability){ status, error in
//...
}
And then I can look up their email address like this:
let userInfo = CKUserIdentityLookupInfo(userRecordID: recordID)
if let email = userInfo.emailAddress{
print(email) // user#example.com
}
But what I'm not clear on, is what is that email address? Is that their actual Apple ID email that Apple stores in their iCloud account? Or is it just whatever they happen to put in the Contacts app on their Mac or iOS device?
I want to know how reliable that email is. If ownership of that email address is not verified through the above techniques, then I'll pursue a different way of getting the user's email address.
Thanks for your help! :)

Powermail Email to friend

I want to create an 'Email to friend' form where the user enters an email address, and an email is sent to that address with a link to the current page url.
How do I set the receiver to be the email entered into the form?
plugin.tx_powermail.settings.setup.receiver.overwrite.email = TEXT
plugin.tx_powermail.settings.setup.receiver.overwrite.email.data = myemailfield??
.data = GP:tx_powermail_pi1|field|markername
But beware that your system can send emails to any email address that a user wants. Someone could use it for spaming with a "tipafriend" function.

Facebook Email field return null (even if the “email” permission is set and accepted) part 2

Here's a link to the topic which described my initial problem.
In short: the problem is that in some cases facebook-graph-api doesn't return the email address of the user.
Other stackoverflow mates suggested to use his Facebook email if he has a user name (i.e. userName#facebook.com) which I've done. But what to do if the facebook user doesn't have "username" there too.
What would you recommend? To redirect him on the page asking his email address?
if you are using PHP Sdk then this part is important:
// $facebook->api('/me?fields=id,email,first_name,last_name,gender,birthday');
$facebook = new Facebook\Facebook([
'app_id' => '{app-id}',
'app_secret' => '{app-secret}'
]);
$accessToken = !empty($_GET['accessToken'])?$_GET['accessToken']:'';
$facebook->setAccessToken($accessToken);
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me?fields=id,email,first_name,last_name,gender,birthday');
// your register function here
// userSignup($user_profile);
} catch (FacebookApiException $e) {
//echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
$user = null;
}
}
There are several reasons why Facebook API doesn't return the email address. Some reasons are listed in https://developers.facebook.com/bugs/298946933534016
Different solutions were proposed to handle this case like in a discussion at https://github.com/mkdynamic/omniauth-facebook/issues/61
But I think using userName#facebook.com is not a good solution, because it's not a valid email, and userName might be not available either, and when you will try sending an email to the user, it will fail to deliver, etc.
Asking a user's email address also is not a good thing to do, since some users might refuse to provide their emails.
I recommend constructing such a fake mail like uid#facebook.yourdomain.com where uid is a user ID guaranteed always to return from Facebook, and a subdomain of your domain where you can handle such fake emails like you want.

Facebook oAuth user details with MVC 4

I am using the OAuthWebSecurity with MVC to allow users of my website to login using Facebook's oAuth. Everything works fine, and I have a test user authenticating fine.
My question is based on the details Facebook can provide. I am currently returning the user details using the following...
AuthenticationResult result = OAuthWebSecurity.VerifyAuthentication();
This will give the follwing details:
UserName (email)
ProviderUserId
I also get a ExternalData object which has:
UserName
Name
Gender
Do you know if it's possible to get further data, maybe DoB, photo etc?
Pardon me for not framing me the full answer. I am just supplying a link. Please check
http://blue-and-orange.net/articles/facebook/displaying-facebook-user-data-in-aspnet-mvc-4/
Everything is explained here.
For setting permission you can go through this documentation
https://developers.facebook.com/docs/facebook-login/permissions/
if you were to request a user's email address, but never asked them for the 'email' permission, you would receive an OAuth error as show below.
try {
var client = new FacebookClient("my_access_token");
dynamic result = client.Get("me/email");
var email = (string)result.email;
}
catch (FacebookOAuthException) {
// The access token expired or the user
// has not granted your app 'email' permission.
// Handle this by redirecting the user to the
// Facebook authenticate and ask for email permission.
}

New Auth Dialog give proxy email address

I start using the new Auth Dialog and I set it to ask for the users email permission, the problem is that I get the user proxy email address (with facebook servers). How can I solve this? I need the user original email.
I'm using JS sdk and FQL to retrive user email, but recieveing proxy email:
FB.api(
{
method: 'fql.query',
query: 'SELECT name, email FROM user WHERE uid=me()'
},
function (response) {
alert('e ' + response[0].email);
}
);
You can't force the user to give you his/her original e-mail address. And I can't see the problem here, whatever e-mail you want to send to the user...Facebook will forward it for you!