質問

私は、iOS SDKを介してFacebookにMultiquery FQL要求をFacebookに送信する方法に関するいくつかの文書またはサンプルコードを探しています。 私はいくつかの古いサンプルを見つけましたが、彼らは私のために働いていません。 照会を使用してNSDictionaryを入力しました。 [[FBRequest requestWithDelegate:self] call:@"facebook.fql.multiquery" params:params];は、サンプルに記載されているように、読み取りができましたが、「認識されていないセレクタはクラスに送信された」というエラーが発生し、FBREQUEST.Hでは「RequestWithDelegate」メソッドを見つけることができません。それは推奨されていませんか? これに関するいくつかの助けは非常に高く評価されるでしょう!

役に立ちましたか?

解決

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

DELEGATE 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。クエリ/

と単一のクエリの代わりにマルチクエリを実行したい場合は、次のようになります。

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top