I'm using the Facebook SDK for iPhone. I need to be able to retrieve the authenticated users details AND profile picture in one request.
In the beta's of the SDK I used to be able to do this using the following code below, but it is now only returning the user id and the picture url.
[FBRequestConnection startWithGraphPath:#"me" parameters:[NSDictionary dictionaryWithObject:#"picture" forKey:#"fields"] HTTPMethod:#"GET" completionHandler:^(FBRequestConnection *connection, id result, NSError *error)...
Is there a way to do this in one request? Many thanks for any advice.
[EDIT] I should also probably mention that I require the URL string to the image directly as I am not using Facebook's new FBProfilePictureView class.
Brain fart! I should have included all the properties I wanted returned in the parameters dictionary. I was under the impression from Facebook's doc that you only had to include the picture property if you wanted it returned WITH the user information. The correct request is as below:
[FBRequestConnection startWithGraphPath:#"me"
parameters:[NSDictionary dictionaryWithObject:#"picture,id,birthday,email,first_name,last_name,gender,username" forKey:#"fields"]
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
}];
Here is an updated solution.
var basicUserData = ["fields": "picture,id,birthday,email,first_name,last_name,gender"]
FBRequestConnection.startWithGraphPath("/me",
parameters: basicUserData,
HTTPMethod: "GET") {
(connection:FBRequestConnection!, result, error) -> Void in
if error != nil {
print(error!)
} else {
print(result!)
}
}
The Parse team recommended getting FB profile picture by accessing the https://graph.facebook.com/(facebookId)/picture?type=large Make sure to replace with the user's Facebook Id. Here is the discussion
Notes:
username field is deprecated after FacebookSDK v2
"/me" is the correct endpoint not "me"
This gist shows many other interactions with the Facebook Graph
Related
I'm trying to get user's list of friends by authanticate user and successfully when I use this code:
self.loginView.readPermissions = #[#"public_profile", #"user_fridends", #"email"];
[FBRequestConnection startWithGraphPath:#"/me/taggable_friends"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
NSLog(#"%#", result);
}];
But I cannot get list of friends when I trying to get list of friends by another account
https://developers.facebook.com/docs/graph-api/reference/v2.1/user/taggable_friends
Use of this edge must be reviewed by Facebook before it can be called on behalf of people who use your app.
Without approval, it will only work for users with a role in the App (Admin/Dev/Tester). The proper way to get the friends is /me/friends, and it will only return those who authorized your App too.
Also, it is "user_friends", not "user_fridends".
i want to get all friend list from Facebook . i am use Facebook version 3.14 SDK . but i got always null data after call Facebook API.
/* make the API call */
[FBRequestConnection startWithGraphPath:#"/me/taggable_friends"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
}];
And Its Permission also give user_friends
I am also put my apps in Facebook Review but i have got alert as below.
I'm trying to send app invites to friends which do not have iOS app installed using Facebook.
In Facebook documentation it says that /me/invitable_friends path is used for it. Problem is that response data is always empty without any error. I've granted user_friends permission.
I have created Canvas page but in Settings I've set Canvas URL to http://localhost.com/facebook/. Thing is that this game needs to be iOS only without Canvas. Is it possible to achieve sending app invites without Canvas?
Here is my request:
[FBRequestConnection startWithGraphPath:#"/me/invitable_friends"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(#"Resulr: %#", result);
NSLog(#"Error: %#", error);
}];
This is the output:
Result: {
data = (
); } Error: (null)
Old question but still unresolved ? For me, that answer fixed the issue : https://stackoverflow.com/a/28596530/2452521
I am trying to get Friendlist details using Facebook iOS SDK using the below query:
if (FBSession.activeSession.isOpen) {
[FBRequestConnection startWithGraphPath:#"me?fields=id,name,friendlists&fields=id,name,members&fields=pic,can_post,id,link,name,pic_crop,pic_large,pic_small,pic_square,profile_type,username,picture,list_type" completionHandler:^(FBRequestConnection *connection,id user, NSError *error) {
}];
I know the mistake is in using the '&' while constructing the query but I am not knowing how to nest the query (to get details like pic, can_post, etc).
Can someone help?
You should do this
me?fields=name,about,accounts.fields(about)
if you'd like to request 'user' (include name, about) and account connection (include 'about' field)
2nd connection you must user . (dot notation) instead of ?fields=
You should use + startForMyFriendsWithCompletionHandler:(FBRequestHandler)handler:
if (FBSession.activeSession.isOpen) {
[FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection *connection,id user, NSError *error) {
}];
}
Note that it would get all the fields from your friends. If you want only a few ones, you can use startWithGraphPath:completion: with #"me/friends?fields=id,name,pic_square as graph path.
I'm trying to use the Facebook SDK 3.2 in my iOS app to get the users facebook news feed. I've successfully got the native facebook login to work and requested the extended read permission.
I guess looking at the documentation I need to use the FBRequest and FBRequestConnection classes but I can't find any examples of this sort of thing on the facebook developer site, at least not enough for me to confidently go on. Must say the tutorials on the facebook dev site aren't as good as they used to be!
Could someone help me out with an example?
EDIT : FQL is deprecated (since 2.0), we should now use the Graph API. The link provided at the bottom of this post shows valuable information, see the red Alert at the top of the screen once you get there.
You will need the "read_stream" permission.
Then use FQL to get the news feed.
I'm doing it like this:
NSString *fqlQuery = #"SELECT post_id, created_time, type, attachment FROM stream WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed')AND is_hidden = 0 LIMIT 300";
// Make the API request that uses FQL
[FBRequestConnection startWithGraphPath:#"/fql"
parameters:[NSDictionary dictionaryWithObjectsAndKeys: fqlQuery, #"q", nil]
HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
if (error)
NSLog(#"Error: %#", [error localizedDescription]);
else
NSLog(#"Result: %#", result);
}];
For more infomation look here: http://developers.facebook.com/docs/reference/fql/stream