Finding FB friends and GMail contacts - ruby-on-rails

I'm a RoR newbie, building an app that allows users to register/link their FB and/or GMail accounts.
For example, User1 registers/links using their FB and Gmail accounts. Once registered, User1 recommends Sushi as their favorite meal.
User2 registers with their FB account, and happens to also be a friend (via FB) of User1. User2 then wants to see what the favorite meals are of people that are registered within the application, and only those they are connected to within FB.
User3 registers with their Gmail account, and happens to be in the contact list of User1. User3 then wants to see what the favorite meals are of people that are registered within the application, and only those they are connected to within Gmail contacts.
In reading the FB/Google API docs, I see that I can query for user's friends and/or contacts, but from a programmatic/performance perspective I'm having trouble wrapping my head around how to accomplish this, especially as the number of users grows. I don't want to store each and every relationship in my DB, so I'm looking for any advice/examples on how to accomplish this.
Thanks for your time and assistance.

that shouldn´t be a problem.
Once your users are registered with your App. You can use for example Facebook FQL API to check which of the FB users friends are registered with your App.
Spotify doesn´t update your friendslist often. You can cache his/her friendslist once a while if you have performance problems inside a NOSQL database since you are already getting JSON from Facebook API.

Related

Mobile app with multiple social logins and contacts fetching strategy

My iOS app offers to the users to login using Facebook, Google+, Twitter or with a custom account. After the login, the user can connect all its social accounts to his account.
The app fetches the user contacts from all the social accounts he has connected.
Scenario 1: New user logs in with Facebook account
the user logs in with Facebook account, the app is authorized from Facebook and an access token is retrieved, so the app has all the details to proceed with fetching the contacts.
while the app is open, the user connect with his Google+ account, the app is authorized and it contains the access token
The app tries to fetch the Facebook and Google contacts -> OK
Scenario 2: Existing user logs in with Facebook account
The app has a fresh Facebook access token, but not a fresh Google+ access token, also if he already authorised the app and the 2 account details are merged.
How can I retrieve the Google contacts?
Is it possible to do it without asking again the user to authorize again the app?
Same scenario can be applied in the case user logs in with Google+ and he want to update the Facebook contacts.
Thanks
Many users sync their Facebook / Google contacts to the Contacts list on their device. You can join this list with users from your database using their emails, and then you have a list of their friends who also use your app. Obviously you have to store users emails in your backend this way, but if you're allowing them to login with multiple social networks, you'll want to do this because then you can map Facebook / Google / Twitter to one user in your app through their email. You also get the added benefit of displaying any friends who they've manually entered into their contact list. I think this is the easiest way.
If you want to go the route of connecting multiple social networks through your app then you would get friends from each social network who use your app through each of the API's (again joining with emails).

iOS Facebook API fetch data from timeline using GRAPH API

We have a facebook account. That account 'Liked' 3 open facebook pages. When you login to that facebook account from your browser you can ofcourse see all the posts from those 3 pages on your news feed.
What I want to know is - can I somehow fetch all the data I see on my accounts news feed?
Im not asking how to do it, just is it possible.
I was doing some research, and on facebook.developers they do mention about nodes, which can be users or groups, but it is unclear to me are those groups that I made, so when I login to my mobile app i Actually login with that group account, or they meant that I can get data or other groups out there ?!
Facebook has documentation using FQL queries to GET the users news feed, take a look here
https://developers.facebook.com/docs/reference/fql
What you are looking for is called stream...

iOS : Send invitation to facebook friends

I am using Facebook SDK to connect Facebook in my app. User will logged in once and will make invitation about MyApp to their friends. I am successful to get ids and name of all Facebook friends. But I couldn't access to email id of Facebook friends. Is there anyway to get access to Facebook friends email ids? So that I can send them a invitation email.
Is there any other ways, that I can accomplish invitation function in application.
I hourly searched on google and so but no results points me to the solution.
Edit:
I've already accepted an answer, that says, there's no ways to get access to friends email id's. So I am looking for some other solution. There should be some solution exist.
Thanks!
There is no way you can get all the email ids of your Facebook friends. But if you have any concept like "Buddies" or "Friends" in your app, you can send request to the mail ids of registered users of your app who is already your Facebook friend. This is how many social network apps like Instagram do.
'Find Friends via Facebook' functionality in Instagram lists out the user's Facebook friends who are already on Instagram.
Eg: A and B are 2 users who are registered on Instagram. A and B are Facebook friends. But A & B are not buddies on Instagram.
While availing 'Find Friends via Facebook' facility, Instagram fetches user's Facebook-email-ID, Facebook-ID etc. Facebook provides API in such a way that user can list out his friends ID. Now, match-making is made to check if any of friend's Facebook-ID is already registered with Instagram. Thus it lists out all the facebook friends of users who are already registered with Instagram so that user can add him/her to the user's buddy-list.
Perhaps this is what you are looking for?
http://developers.facebook.com/docs/tutorials/ios-sdk-games/requests/
You can't. Unless they make their emails public
https://developers.facebook.com/docs/reference/api/user/

Is it possible for a Facebook page to access the ID's of every user who 'likes' that page using Facebook Connect for iOS?

I am making an app in Xcode which has users register via Facebook, their ID number is then stored in our database along with their device token so that we can send them push messages.
In order to have companies use the app, we would like them to be able to send messages to all registered users who also like their Facebook page. Obviously this means accessing a potentially huge list of IDs, but tbh I'm not sure this is even possible.
Presumably it's not done in the same way as accessing a profiles friends list as they are not friends (would they be fans? likes?). I can access a users friends list easily enough, but I would be appreciative if someone could point me in the right direction as to whether the same thing is possible for business pages.
Thank you.
Facebook doesn't allow access to userId's unless they specifically allow an app permission. This can be done via asking for any permission and a userId will be given.
In your other case you get around this because a user gives permission to access their friends list.

multiple oauth providers and implicit user account creation

I'm learning oauth 2.0 and was wondering about the following scenario
say I want a website to allow login with both twitter and facebook
when a new user logs in for the first time using twitter, the server checks if a user with this twitter id exists in the database and if not, creates a new user using values returned from twitter
the same user logs out and logs in again, this time using his facebook account
Question: how can I match the returning user with the account that was created the first time and avoid creating a second user account for the same user ?
Thanks
If you request for their email address, you can detect matches and merge that way?
If you are only interested in having the user log in, then you should be looking at openID, not OAuth.
Unless you explicitly ask the user to link their various accounts together for your app, there really isn't a good way to know that JohnDoe on Twitter is JohnDoe on Facebook.
You can ask the customer to link their accounts together and give them tools to merge two accounts (one created with Twitter account and one with Facebook account) together.

Resources