I am looking to combine a call to Facebook Graph API. I would like to collect both the friends and profile information in one go.
I have also raised a separate question issue here - Facebook SDK collecting user information and friends
What is the correct/easiest way to create a Facebook Graph request for both these parts?
The user is logged in with this permission array:
NSArray *permissionsArray = #[ #"user_about_me", #"user_birthday", #"user_location", #"email"];
I am then trying to create a graph connection to get information 'such as' username, email, friend list. Ideally I want to do this in one FBRequest, rather than separate FBRequestConnection(s). How can I accomplish this? I have looked through the Facebook SDK information and cannot see how to do this, how can I find out more information on this?
You can get all of this information in one API call to:
/me?fields=id,username,email,friends
I'm not sure of the syntax for iOS.
If you want more data about your friends, you can specify fields through field expansion, like this:
/me?fields=id,username,email,friends.fields(id,name,username,birthday)
Related
I linked the user with their Facebook account with linkUserInBackground, and their Facebook ID is stored under authData inside the Parse.com database. I want to access this particular Facebook ID to retrieve the user's profile picture. Is this possible? If it is, how can I do so?
I think there are nothing to do with Parse.com, their linking function is just for logging user in.
You can call API from Facebook iOS SDK in order to get that image.
EDIT:
Although you use your Facebook ID to log in, you won't get the authData back when you query for it. So, the best way to do is to have your own custom field to store the Facebook ID so that it's available for you when you fetch it.
Extremely helpful documentation for getting Facebook ID after logging in:
I'm trying to get the email addresses of friends of logged in User, from my iOS App using the
[GTLQueryPlus queryForPeopleListWithUserId:#"me"
collection:kGTLPlusCollectionVisible];//kGTLPlusCollectionVisible
I have made authentification scopes like described in the Google Docu:
signIn.scopes = #[
kGTLAuthScopePlusLogin,
kGTLAuthScopePlusMe,
kGTLAuthScopePlusUserinfoEmail,
kGTLAuthScopePlusUserinfoProfile,
#"email",
#"https://www.googleapis.com/auth/plus.profile.emails.read",
#"https://www.googleapis.com/auth/plus.circles.read"
];
Result is, I get the list of friends, but WITHOUT the Email address. As I do not get any error message, I'm really stuck, and have no solution
Can someone help?
Thx.
Patrik
The email scopes only work for the currently authenticated users profile. They don't enable access to the email addresses for other profiles.
I have a rails app that uses omniauth for Facebook login. I also use fb_graph to get the user's friends list. Instead of displaying ALL of the current_user's friends, I only want to display his friends who have used my app before.
The way I am thinking of doing this is adding a field to my user model that I can check in the view that I display the friends from. So for example
graph_user = FbGraph::User.me(current_user.oauth_token)
#friends = graph_user.friends
in the controller. Then in the view I can have:
#friends.each do |friend|
- if User.find_by_uid(friend.uid)
# display that friend
unfortunately, 'friend' doesn't have a uid but users who are authenticated obviously do. Is there something I can request from Facebook upon creating a new user, maybe email?, that I can check later against 'friend.'
Would checking email be ok? Currently we don't request email from Facebook login, but if I did, I don't think friend.email would allow me to collect that either, would it? What is a better way?
EDIT: I found this other SO post that says I can grab access tokens from friends or something, but I don't really understand, maybe someone could shed some light or point me to a tutorial?
Thanks
You can use fql directly to get the friends who use the app. I'm not sure how to use fql in ruby but this post might help you- Facebook FQL Query with Ruby
The query to get the friends who use the app-
SELECT uid FROM user WHERE is_app_user=1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
(user table)
I'm making an app and decided to go with a Facebook Login to log users into the app. This seems to be fairly easy, and Facebook has a great number of tutorials to use.
However, I want to retrieve (from my online database) a certain set of information related to individual users when the user logs in. How would I go about that?
That includes creating a row in my database for that specific user when it's his first time logging into the app (equivalent of registering for the app), and then inserting and retrieving information in different columns on that row.
So to start, how would I store that user in the database? Normally I'd have a user_id linked up to a username and password combination, but this time I don't have neither a username nor a password. I can't use their name, as more there might be more than one person with a name. Does Facebook give access to their user_id? If so, how do I retrieve it? If not, how would I go about doing that?
All your help would be greatly appreciated!
The Facebook FBGraphUser class provides access to basic user information including id and username properties. You don't say which method of logging in to Facebook you are using, but the Facebook Login Button/Login View calls the delegate method loginViewFetchedUserInfo:user where user is the FBGraphUser.
If you use the lower-level APIs then you will need to use the Graph API to obtain the user information.
A sample delegate method would be -
- (void) loginViewFetchedUserInfo:(FBLoginView *)loginView user:(id<FBGraphUser>)user
{
NSLog(#"Facebook user id is %# and user name is %#",user.id,user.username);
}
I'm writing an app that will feature SSO via Twitter.
So far, using the built-in functionality in iOS 5, I've been able to come up with something like this using internet search results:
if ([TWTweetComposeViewController class])
{
TWTweetComposeViewController *tweeter = [[TWTweetComposeViewController alloc] init];
[tweeter setInitialText:#"Greg can't figure out Twitter in iOS 5"];
[self presentModalViewController:tweeter animated:YES];
}
How would I get the Twitter user's "User ID" (#gregkrsak, in my case), if I wanted to store it for later use?
The TWTweetComposeViewController does not give you access to the user's Twitter user ID, just as the MFMailComposeViewController does not give you access to the user's email address.
Fortunately, you can retrieve the user's Twitter user IDs (there may be more than one), but it takes a little more work. You will need to create an ACAccountStore object, query it for all Twitter ACAccount objects, and then extract the account.username property for each. In the process, the user will see an alert asking if he wants to give the app access to his Twitter accounts.
It's not hard to do all this, and a great resource is the WWDC 2011 session video (and slides) on Twitter.