Calling FQL queries from the iPhone fbconnect libraries - iphone

I started developing an iPhone application in June 2010 that used the Facebook APIs extensively. I logged in and got a FBSession which contains the logged in user's profile id, etc. I then used the FBRequest class to make many calls using the FQL to get data.
How do I call FQL queries from the latest Facebook Connect APIs?

NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"SELECT uid,name FROM user WHERE uid=4", #"query",
nil];
[_facebook requestWithMethodName: #"fql.query"
andParams: params
andHttpMethod: #"POST"
andDelegate: self];

Related

How to send add friend request (to facebook user) from iOS application?

I know there are lot of questions on this topic but none of those have satisfactory answers. Again I am not so confident about help as 2 of my last 3 questions are unanswered. Well Still, ma question is, Is there any way we can send friend request to any facebook user from one iOS application? Of course we have user id of that user.
As I have googled much and went through many links including
how send friend request to a person in Facebook through iPhone app?
Can a facebook friend request be sent from my own app?
https://developers.facebook.com/docs/reference/dialogs/requests/
etc..
And finally I found it:
http://www.facebook.com/dialog/friends?id=100002487216939&app_id=123050457758183&redirect_uri=http://www.example.com/response/
This dialog do the same what I want. So is there any equivalent for this in graph. Or something in iOS sdk, FBDialogueDelegate. Any thing that can help me out.
For user-to-user requests, you can do this (using ARC):
NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys: message, #"message", title, #"title", nil];
[[self facebook] dialog: #"apprequests"
andParams: [params mutableCopy]
andDelegate: delegate];
For app-to-user requests, you can do this:
NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys: message, #"message", nil];
[[self facebook] requestWithGraphPath: #"[FRIEND ID]/apprequests"
andParams: [params mutableCopy]
andHttpMethod: #"POST"
andDelegate: delegate];
Make sure you have the right access tokens and the correct Facebook configuration (canvas page setup etc.) for each.

Creating a Facebook event on public FB Page using iPhone SDK Graph API

I'm trying to let users create an event on my public Facebook page via an iPhone app, and hopefully let ppl invite their friends to that event.
The idea is that the iPhone app will be able to show the users events from that page, while everyone is able to add the events.
After Authorizing with permissions: create_event and manage_pages, i'm trying to run the following code:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"My Event",#"name",
PAGE_ID, #"page_id",
#"2011-11-10T13:30",#"start_time",
#"2011-11-11T13:30",#"end_time", nil];
[facebook requestWithGraphPath:[NSString stringWithFormat: #"%#/events", PAGE_ID]
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
And I get and error saying: "(#200) Permissions error".
Is it even possible? (creating an event on a page which a user doesn't own)
and if so, what am I missing?
permissions = [[NSArray alloc] initWithObjects:#"offline_access", #"user_events",#"create_event",#"rsvp_event", nil];
I hope that it is just your help.

postToWall on facebook After login in iphone

Does anybody have idea about how to post a wall on
facebook after login button in iphone.
i have to post default image and text.
If yes in which fb class it have to write .i have latest sdk for facebook.
Thanks
using FBConnect library after login you can use the following method to post on the users wall
Facebook *facebook = [[[UIApplication sharedApplication] delegate] facebook];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"###yourAPIKeY###", #"api_key",
#"###Your Message###", #"message",
#"###link if you want###", #"link",
#"### a picture if you want###", #"picture",
#"###name of your fb app###", #"name",
#"###Description###", #"description",
nil];
[facebook requestWithGraphPath:#"me/feed"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
If you want it to happen right after the user logged in it should be implemented in the following method:
-(void) fbDidLogin
{
}
be sure to note that you need to ask from the user publish_stream permissions

Getting friends of friends with Facebook iOS SDK

Is it possible to get information about friends of my friends using facebook ios sdk?
Please.If it is possible give an example.
request with Graph api #'[friend_id]/friends" does not work.
'code' [facebook requestWithGraphPath:#"[friend_id]/friends" andDelegate:self];'code'
i try this code but it returns
Error:facebookErrDomain error 10000 where'code'
facebook = [[ Facebook alloc] initWithAppId:app_id];
NSArray *permissions = [NSArray arrayWithObjects:#"I try all permissions"];
[facebook authorize:permissions delegate:self]; 'code'
user is logged in, All information about this friend is available
I'm quite sure this is not possible, you'ld need data access privs of the friends to get their friends data. this has to do with the access rights on fb and this is good for some reasons it is like it is. even if this data protection mechanism disturbs your business idea ;)
If you want catch friend informations you must :
Alloc and Init a Facebook object
Facebook *facebookObject = [[Facebook alloc] init];
Check permissions
NSArray *permissions = [NSArray arrayWithObjects:#"publish_stream", #"offline_access",nil];
Authorize facebook
[facebookObject authorize:APP_ID permissions:permissions delegate:self];
After that you can used
[facebookObject requestWithGraphPath:#"me/friend" andDelegate:self];
In delegate methods
- (void)request:(FBRequest *)request didLoad:(id)result
You catch the result who must be a NSDictionnary.

Publishing links to user's wall using Facebook iOS SDK

I'm trying to publish a link to the user's wall on Facebook after he has already logged in using the new Facebook iOS SDK.
I want the link to behave as if the user posted it from his account. For example, if I post this link on my Facebook wall: http://www.apple.com/, I won't see the link. What I'll see is an image, a caption with the actual url and a short description. But when I publish this same link from my app, all I see is the link itself.
How can I publish this url through my app so that what will eventually appear on the user's wall is the formatted message as it would appear if he would have posted it from his account on the pc, and not just the link itself as a string?
Thanks,
EDIT: The code below is for an OLD version of the FB SDK
Check here for a more up to date answer that may help Facebook sdk post on wall on iPhone app
OLD POST:
From http://developers.facebook.com/docs/reference/dialogs/feed/
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId, #"app_id",
#"http://developers.facebook.com/docs/reference/dialogs/", #"link",
#"http://fbrell.com/f8.jpg", #"picture",
#"Facebook Dialogs", #"name",
#"Reference Documentation", #"caption",
#"Dialogs provide a simple, consistent interface for apps to interact with users.", #"description",
#"Facebook Dialogs are so easy!", #"message",
nil];
[_facebook dialog:#"feed" andParams:params andDelegate:self];
You need to use FBStreamDialog for this. I do not have the exact code. Try this:
FBStreamDialog* dialog = [[[FBStreamDialog alloc] init] autorelease];
dialog.delegate = self;
dialog.userMessagePrompt = #"What's in your mind?";
dialog.attachment = #"{\"name\":\"Apple URL","
"\"href\":\"http://www.apple.com\","
"\"caption\":\"App Name\",\"description\":\"Posting link Test\","
"\"media\":[{\"type\":\"image\","
"\"src\":\"http://www.apple.com\","
"\"href\":\"http://www.apple.com\"}],"
"\"properties\":{\"another link\":{\"text\":\"Apple home page\",\"href\":\"http://www.apple.com\"}}}";
[dialog show];