簡體   English   中英

iOS SDK中的Facebook FQL多重查詢

[英]Facebook FQL multiquery in iOS SDK

我正在尋找有關如何通過iOS SDK向Facebook發送多查詢fql請求的一些文檔或示例代碼。 我找到了一些較舊的樣品,但它們對我不起作用。 我用查詢填充了一個NSDictionary ,我嘗試通過[[FBRequest requestWithDelegate:self] call:@"facebook.fql.multiquery" params:params];發送請求[[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];

將使用響應調用委托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/

如果你想做一個Multiquery而不是一個查詢,它看起來像:

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 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM