Facebook friends Location info in iPhone app - ios

Any one having a idea how to get Facebook friends location details from Facebook profile.
I am getting these details (id,name,gender,email, picture) using this graph API.
I also need location information.
Thanks!

To get friends location for 1.0 graph api,you can use following code.
if (FBSession.activeSession.isOpen) {
[FBRequestConnection startWithGraphPath:#"me/friends?fields=name,location,installed,picture"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
NSDictionary<FBOpenGraphObject> *my,
NSError *error
) {
NSDictionary *resultDictionary = (NSDictionary *)my;
if ([resultDictionary valueForKey:#"data"]) {
NSString * latitude = [NSString stringWithFormat:#"%#",[[my2 valueForKey:#"location"] objectForKey:#"latitude"]];
NSString *longitude=[NSString stringWithFormat:#"%#",[[my2 valueForKey:#"location"] objectForKey:#"longitude"]];
}
}];
}
Important Note me/friends will only return you those friends who have authorized your app since graph api 2.0 as mentioned here in facebook docs And all friends info are removed as mentioned except basic info like name , id , picture as mentioned here
In v1.0, it was possible to ask for permissions that would allow an
app to see a limited amount of friend data, such as a person's
friend's likes, their birthdays, and so on.
In v2.0, those permissions have all been removed. It's no longer
possible for an app to see data from a person's friends unless those
friends have also logged into the app and granted permission for the
app to see it that data

Related

how to get all friends in facebook using graph api v2.0 (ios)?

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".

Getting the user’s Facebook list of friends

After being able to create a small iOS app that logs in to Facebook. I would like this app to get the user’s list of friends.
Though I browsed the internet for a while and tried various approach I did not succeed to get what I wanted.
In the viewDidLoad method I use this code to start with:
loginView = [[FBLoginView alloc] initWithReadPermissions:#[#"user_friends"]];
And then I implement the loginViewFetchedUserInfo: user: method this way:
- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
user:(id<FBGraphUser>)user
{
[FBRequestConnection startWithGraphPath:#"/me/friends"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
NSLog(#“Result: %#",result);
}];
}
When I execute the app I get this result:
Result: {
data = (
);
summary = {
"total_count" = 267;
}; }
But what I really want is a list of the friends with their names …etc…
All the things I tried for that didn’t work. Though I suppose the solution must be simple.
I also used code like this in the method above ….. but with no luck:
NSArray* friends = [result objectForKey:#"data"];
One more point, here https://developers.facebook.com/docs/graph-api/reference/v2.1/user/friends one can read:
This will only return any friends who have used (via Facebook Login)
the app making the request.
But the result I get (267) does not match this statement. It (267) is the number of friends the user has on Facebook, which is in fact what I am interested in.
I hope someone has something to say to put me on the right track and make things clearer.
Since Facebook's 2.x SDK upgrade they have tightened up access to information in the "Open Graph API."
Under Permissions That Do Not Require Review
App friends. This optional permission grants your app the ability to read a list of friends who also use your app.
You get automatic access to any friends that already use your app (per its Facebook ID.)
You will have to request Extended Permissions if you want to access the list of all a user's friends. That means going through Facebook's App Review process which can be quite challenging (and annoying.)
Frankly, I am not even sure that it is possible to use the new Open Graph API to get the user's entire friend list.

Facebook requestForMyFriends returns no friends data [duplicate]

This question already has answers here:
Facebook Graph API v2.0+ - /me/friends returns empty, or only friends who also use my application
(8 answers)
Closed 8 years ago.
I used the FBRequest to request the friend list of user.
FBRequest *requestFriendList = [FBRequest requestForMyFriends];
[requestFriendList startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error){
if (!error)
{
NSArray *fbFriends = [result objectForKey:#"data"];
//...
}
}];
However, the returned result of the request didn't contain any data. I printed out results, it contains the friend count, but no data inside.
Printing description of result:
{
data = (
);
summary = {
"total_count" = 585;
};
}
If the request failed or the app doesn't have permissions, should it return an error or the "total_count" also is not shown?
So is there anything I did wrong? Anyone can help me fix this problem?
Thanks!!
Graph API 2.0 changed the behaviour of the /friends endpoint.
It now returns the list of friends who have authorized your Facebook app, as opposed to the complete list of friends. It's also a new permission - user_friends.
From the Facebook Platform Changelog:
Friend list is no longer part of the default permission set and has
its own permission: Asking for access to a person's friend list is now
a separate permission that your app must request. The new permission
is called user_friends.
Friend list now only returns friends who also
use your app: The list of friends returned via the /me/friends
endpoint is now limited to the list of friends that have authorized
your app.

How to get all the friends of the user in FB using iOS SDK

FaceBook launched new API from version 2.0 and asking users to upgrade to new SDK.
In my iOS application (which is not a game), user signs in using Facebook. In side the application I have an option to show all the FB friends of the user (friends who are not using the application).
I tried the below code which returns the friends who are using the application:
[FBRequestConnection startWithGraphPath:#"/me/friends"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
NSLog(#"%#", result);
}];
And below code is not working in my application, because my app is not a game. As per FB, below code works only for Games.
FBRequest *request = [FBRequest requestWithGraphPath:#"me/invitable_friends"
parameters:#{#"fields":#"name,installed,first_name"}
HTTPMethod:#"GET"];
[request startWithCompletionHandler:^(FBRequestConnection *connection,
id result,
NSError *error){
NSLog(#"%#", result);
}];
Is there any other alternative to fetch the friends of the user?
According to the document, with the new Facebook Graph API 2.0, there is no way to fetch all friends.
Friend list now only returns friends who also use your app: The list
of friends returned via the /me/friends endpoint is now limited to the
list of friends that have authorized your app

Facebook iOS SDK 3.2 get users news feed

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

Resources