I am looking for some documentation or sample code on how to send multiquery fql requests to Facebook via iOS SDK.
I found some older samples but they doesnt work for me.
I have populated an NSDictionary
with the queries and I try to send the request via
[[FBRequest requestWithDelegate:self] call:@"facebook.fql.multiquery" params:params];
, as stated in the samples I have read, but I get an "unrecognized selector sent to class" error and I cant find the "requestWithDelegate" method in FBRequest.h either. Is it deprecated?
Some help on this would be very appreciated!
Asked
Active
Viewed 6,555 times
8

Paul Peelen
- 10,073
- 15
- 85
- 168

jonasonline
- 117
- 1
- 5
-
Have you checked out the Facebook IOS SDK? This open source iOS library allows you to integrate Facebook into your iOS application include iPhone, iPad and iPod touch. The SDK is lightweight and has no external dependencies. Getting started is relatively easy. https://github.com/facebook/facebook-ios-sdk/ – gotnull May 17 '11 at 06:32
1 Answers
14
// Construct your FQL Query
NSString* fql = [NSString stringWithFormat:@"SELECT uid, name, hometown_location from user where uid IN (SELECT uid2 FROM friend WHERE uid1=%lld) and hometown_location != '' ORDER BY rand() limit 4", facebookId];
// Create a params dictionary
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObject:fql forKey:@"query"];
// Make the request
[facebook requestWithMethodName:@"fql.query" andParams:params andHttpMethod:@"GET" andDelegate:self];
The the delegate FBRequestDelegate will be call with the response. Depending on your needs, you'll do something like:
- (void)request:(FBRequest*)request didLoad:(id)result {
NSLog(@"didLoad() received result: %@", result);
}
The facebook object is created like:
Facebook * facebook = [[Facebook alloc] initWithAppId:kAppID];
More info on how to set this up can be found here: https://developers.facebook.com/docs/guides/mobile/
And depending on your FQL query, you will need permissions from the user. See the list of permissions here: https://developers.facebook.com/docs/authentication/permissions/
There is also a test console for FQL queries here: https://developers.facebook.com/docs/reference/rest/fql.query/
And if you want to do an Multiquery instead of a single query, it would look like:
NSString* fql1 = [NSString stringWithFormat:
@"select uid2 from friend where uid1 == %lld order by rand() limit 10", facebookId];
NSString* fql2 = [NSString stringWithFormat:
@"select uid, name from user where uid in (select uid2 from #queryID)"];
NSString* fql3 = [NSString stringWithFormat:
@"select uid, status_id, message from status where uid in (select uid from #queryName) limit 1"];
NSString* fql = [NSString stringWithFormat:
@"{\"queryID\":\"%@\",\"queryName\":\"%@\",\"queryStatus\":\"%@\"}",fql1,fql2,fql3];
NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"queries"];
[facebook call:@"fql.multiquery" params:params];

ddiego
- 3,247
- 1
- 28
- 18
-
1What is queryID and queryName ? can you please explain little bit ? Thanks.... I use multi query as you mentioned but returns null. – Maulik Apr 19 '13 at 05:28