Facebook integration and event fetching in ios - ios

Hi I am working in xcode 6.4.
I am trying to create an application which integrate with Facebook.I want to fetch the event details of the user. That is, I want event_name, place, time, number of friends going and their details. I found many answers for this problem here and I tried them. But I couldn't build the app with that much of information. Please give me a detailed solution for the same.
[FBRequestConnection startWithGraphPath:#"me/events"
parameters:#{#"fields":cover,name,start_time,end_time"} HTTPMethod:#"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
if (!error)
{
NSLog(#"event_name%#",[result objectForKey:#"name"]);
NSLog(#"start_time%#",[result objectForKey:#"start_time"]);
NSLog(#"end_time%#",[result objectForKey:#"end_time"]);}
else
{
NSLog(#"%#", [errolocalizedDescription]);
}
}];

Related

Is that possible to get User post from liked page of facebook using facebook SDK

Hi right now i am trying to get all post of user that post on particular page. i am using that method for get first all pages that logged in user Liked.
[FBRequestConnection startWithGraphPath:#"/me/likes"
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
// NSLog(#"reselut %#",result);
/* handle the result */
}];
Then for particular Page feed i get all post using bellow method:
[FBRequestConnection startWithGraphPath:#"/123456789/feed" //as documentation said that need to put page-id
parameters:nil
HTTPMethod:#"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
NSLog(#"reselut %#",result);
/* handle the result */
}];
I read and trying to implimetation using https://developers.facebook.com/docs/graph-api/reference/v1.0/page/feed there is said.
/{page-id}/feed
The feed of posts (including status updates) and links published by this page, or by others on this page. There are other edges which provide filtered versions of this edge:
/{page-id}/posts shows only the posts that were published by this page.
/{page-id}/tagged shows only the posts that this page was tagged in.
/{page-id}/promotable_posts shows only the posts that can be boosted (includes unpublished and scheduled posts).
All of these derivative edges share the exact same reading structure, however /feed should be used for all publishing purposes.
But i would like to get only those post that posted by logged in user in to particular page. is that possible or not. and if yes then please guide me on this.

Facebook iOS invitable_friends returns empty data

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

Facebook graph api and nested query

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.

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

iPhone Facebook SDK 3 get user details & profile pic in one request

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

Resources