8

マルチクエリ fql リクエストを iOS SDK 経由で Facebook に送信する方法に関するドキュメントまたはサンプル コードを探しています。古いサンプルをいくつか見つけましたが、うまくいきません。にクエリを入力NSDictionaryし、読んだサンプルに記載されているように、を介してリクエストを送信しようとし [[FBRequest requestWithDelegate:self] call:@"facebook.fql.multiquery" params:params];ましたが、「認識されないセレクターがクラスに送信されました」というエラーが発生し、FBRequest.h で「requestWithDelegate」メソッドが見つかりません。また。非推奨ですか?これに関するいくつかの助けをいただければ幸いです。

4

1 に答える 1

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];

デリゲート FBRequestDelegate は、応答とともに呼び出されます。必要に応じて、次のようにします。

- (void)request:(FBRequest*)request didLoad:(id)result {
    NSLog(@"didLoad() received result: %@", result);
}

facebook オブジェクトは次のように作成されます。

Facebook * facebook = [[Facebook alloc] initWithAppId:kAppID];

これを設定する方法の詳細については、 https ://developers.facebook.com/docs/guides/mobile/ を参照してください。

また、FQL クエリによっては、ユーザーからのアクセス許可が必要になります。ここでアクセス許可のリストを参照してください: https://developers.facebook.com/docs/authentication/permissions/

FQL クエリのテスト コンソールもここにあります: https://developers.facebook.com/docs/reference/rest/fql.query/

また、単一のクエリではなくマルチクエリを実行する場合は、次のようになります。

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];
于 2011-06-16T12:58:04.627 に答える