Getting Yahoo contact names and email addresses using YQL - contacts

I'm trying to build a web application in which users can invite their friends by using their email accounts (just like facebook). I use OAuth so that users don't need to enter password in my app. The problem is that I cannot figure out what is the correct YQL query to fetch contact names and email addresses from Yahoo social tables, and achieve the same result with facebook's Find Friends feature.
At first I used this:
SELECT * FROM social.contacts(0, 500) WHERE guid=me
With this query I hope I can get all contacts of the current logged in user, at once. But after parsing and selecting only records which have email field, the result list is far less than when I'm using facebook's Find Friends. I guess facebook does not only using Contacts tables, but also Profile tables, as I see it in the Yahoo authorization page when granting access permission to my private data.
So what is the correct YQL query to get all contact names and email addresses, using these two tables ?

After trying some tests, I discovered that when I import email addresses from my Yahoo contacts, Facebook automatically guesses the contact's email address in case that contact does not have an email field, by appending #yahoo.com to its yahooid field. As I see, this is totally wrong. Because with a yahooid, say "john123", the associated email may have an international domain like john123#yahoo.co.uk, john123#yahoo.com.vn etc.
I have a friend in my Yahoo contacts list. He has a yahooid which associates with a #yahoo.com.vn email address. Before importing my Yahoo contacts into Facebook, I made sure that there is no email field in his contact entry, just a name and a yahooid field. After importing into Facebook, Facebook determines my friend's email address as a #yahoo.com email. Of course the Facebook invitation mail never reach him.
And so, the answer to my question is: there is nothing wrong with my YQL. Facebook can fetch more email addresses than I do, but many of them are incorrect.

Related

API to fetch the contacts from domain email address

I have get the contacts from gmail,hotmail and yahoo email providers.
And i want to get contacts from any domain email addresss which users enter in a textbox. Is it feasible?
For example,
Here we can see the hotmail contact import: https://techjoomla.com/invitex/how-to-use-hotmailrest-api-to-import-contacts.html
Same way i want to import contacts from a domain email. i.e say if i have this email address test#stackoverflow.com and having few contacts.
Using PHP, i want to fetch the contacts from test#stackoverflow.com
Hope the above provided detailed explaination.
So, what you want is possible if that mail server allows you to access the contacts you have there. But, I am pretty sure that you will definitely not be allowed to fetch contacts from every single mail server you want. But, I would suggest you to give that try before losing hope.

API for looking up Gmail user's public full name?

Is there an API to look up the same information that I can get from Gmail if I type someone's email address into Gmail's search bar and hit search? For most Gmail addresses, this shows me the person's full name.
I ask for people's email address when they sign up on my website, but not for their names. I'd like to add a personal greeting to the emails that I send out. Note that people have NOT signed up using Google+.
You're looking for the new People API.

Is it possible to check if an email is confirmed on Facebook?

Update
This was reported to Facebook via https://www.facebook.com/whitehat/report/ on Dec 16th 2013 and Facebook responded on Dec 17th that the bug has long since been fixed.
I have retested this with my Facebook account (that I still haven't verified the email address on) and when using the Grap API Explorer tool it is not possible to get the email address of this account using the Graph API or using a FQL query.
Conclusion: The email address you get from Facebook using the Graph API or a FQL query is a verified email. If an account hasn't verified it's email yet it's not possible to get it.
Original Post
I am making a web app with SSO that is offering the user to sign in with either Google or Facebook. I would like users who have both types of accounts to show up as the same user in my system regardless of which identity they log in with. To achieve this I'm thinking of using the email address as the identifier to know if I should create a new account or if the user already exists.
To not introduce any security problems I must know that the email address is verified and actually belongs to the user. For Google the userinfo API can tell me if an email is verified or not, so there's no problem here. But I can not find anything like this in the Facebook Graph API.
Is it possible to know if an email address is confirmed on Facebook?
I know that there is a verified field, but that only tells if the account is verified and not the email address.
At first it looked like you are only able to use the Graph API for accounts where the email address has been confirmed. If the address wasn't confirmed I just got an error telling me that I had to confirm the email address first before being able to sign in to any third party site.
However this does not seem to be true for all accounts. In some cases it's possible to get accesses to all parts of Facebook even if you don't have a confirmed email address. One example of this is when you sign up with a #myopera.com mail address.
When you sign up to Facebook with a #myopera.com email address you get a message that your account has been temporarily locked as soon as you submit the sign up form. To continue you need to provide your phone number to verify your account and to "keep Facebook safe and free from spam" (sorry for the Swedish in the screenshot, this was before I could get into Facebook and change language to English):
When you provide your phone number you are logged in and Facebook doesn't nag you any further about that you have to verify your email address.
The only place where you can see that your email address is not yet verified is on the settings page:
The Mobile Settings that is usually not accessible before you have verified your email address is available and lists the phone number entered during sign up:
In addition to this it is also possible to log in to third party sites with an unconfirmed email address:
When I connect to the graph api with this user I can get the unconfirmed email address and the verified field returns true as expected since I have verified the account by adding a phone number. So obviously I can't trust that the email address I get from Facebook really belongs to the user that has the Facebook account.
Is there any other way of knowing if the email address is verified or not or do I have to verify it myself if I want to use it for identifying the user?
I was looking for an official Facebook statement regarding this issue and finally i found this: https://developers.facebook.com/docs/facebook-login/multiple-providers#postfb1, which clearly says that developer should not rely on the fact that email address is verified.
I've never used it, but you may be able to check with a FQL query of the user.email_hashes: http://developers.facebook.com/docs/reference/fql/user

Register with Facebook sometimes doesn't provide email

I'm using Register with Facebook as one of the ways to log in to my web app, and expressly ask for the "email" permission..
On login, some of the user data ($facebook->api('/me')) is stored into the users database, however, sometimes the email field just doesn't exist - is this a common problem?
Just a guess...
The facebook documentation says:
note: this field will not be returned if no valid email address is available for the user
Source: https://developers.facebook.com/docs/reference/api/user/
So when an email address become invalid (users who haven't used facebook in years and have destroyed/changed their email address since for example), facebook may stop returning this field.
5% of invalid address may sounds big, but if I check my facebook friends, I think more than 5% of them never use their account, and I wouldn't be surprised if the address they used when they signed in is now invalid.
Users don't always have to provide an email address in order to use Facebook. They can also sign up via SMS, though it's far less common.
In short, FB won't always have an email address, so can't serve it to your app.
Try:
// Just to make sure email are permitted
//$facebook->getLoginUrl(array('req_perms' => 'email'))
// Request email
FB.api('/me?scope=email', function(response) { /*...*/ });
Or:
$email = $facebook->api('user_id?fields=email');
PROBLEMS:
The user changed the visibility of its email address to "only me" and thus you have no way to get it.
The user registered with SMS instead of email as mentioned in the previous answer.
ALTERNATIVE:
If you absolutely need to contact the user but you cannot get its email address nyou can still get its Facebook email (everybody has this email): "user_name#facebook.com".
If the user uses a POP server he will directly receive the email in GMail or others, if not he will receive your email as a private message. The only drawback if this method is that your email must be "plain/text" and not "HTML".
One thing is Users don't always have to provide an email address in order to use Facebook(could have registered through mobile)- as mentioned by Colm. Apart from this-
Please check that if the user has definitely granted you the email extended permission or it hasn't subsequently been revoked. To have a check on this you could use the permissions api-
/USER/permissions
I had similar problem & I found the cause for this. This problem occurs for users who have not set their Primary Email Address (They have many email address but they haven’t pointed out which is their primary email address) under General Account setting tab.
I tried using such accounts on various famous sites which has Facebook login & even they couldn’t retrieve the email address from such accounts.
So, its not the problem with the code(Assuming u have asked for permissions). We just have to handle such scenarios & let users know that we didn’t receive their email address. Like Klout does.
Thanks
In addition to what #Jigar Jain wrote above, users can actually uncheck the email permission during the sign inflow. If that's the case, his/her email address will not be returned by Facebook.
It's up to you to implement a logic that makes login unsuccessful if user unchecks the email permission, to force your users to choose another login method that will guarantee that a return of user's email address.
It is not mandatory for someone to give their email address while signing up with Facebook. An alternate approach would be to ask the user to link their email id in the Facebook account settings. That way you can fetch the email id, if that's a mandatory field in your DB. Otherwise you can continue with the id provided by FB which is unique.

Facebook API does not allow this. So how does Hotmail get email and phone number of friends?

From what I can see so far, the facebook API does not allow you to extract the email address and phone number of your friends - it just returns an empty/null string. If that is the case, how does Hotmail/ Windows Live Mail do it? It allows you to import all of your contacts from facebook, including their email address and phone numbers.
Yahoo and Hotmail have special agreements in place with Facebook to allow syncing with your webmail account. Regular facebook applications don't ever allow access to friend email addresses, only the current users if email permissions are granted.