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
Related
I'm trying to fetch Facebook posts for a public page using the Facebook SDK for iOS. I can't seem to figure out how to get and then use the access token I need to make this request. Let's say it's the New York Times page. This shouldn't require any permissions, so I should be able to use the App Access Token...but again, I can't figure out how to get & use that.
The code I am using looks like this:
[FBRequestConnection startWithGraphPath:#"/nytimes/posts" completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
NSLog(#"DATA: %#", [result data]);
NSLog(#"ERROR: %#", error);
}];
I keep receiving an error saying that an access token is required.
Please help!
It means it asking you a permission to access the public post in view did load method put one line code like (readPermissions = #[#"public_profile", #"email",#"user_friends",#"user_likes",#"user_groups"];)
, for more details see this https://developers.facebook.com/docs/facebook-login/permissions/v2.2.
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".
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
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
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