1
我正在嘗試使用Facebook查詢來獲取援助(專輯ID)列表。在做Facebook查詢時沒有返回任何結果
什麼工作:
運行來自瀏覽器的查詢返回的結果,但是當我使用Facebook Connect不返回任何值運行。
我遇到的問題是特定於相冊對象,查詢用戶表時我得到了結果。
我能想到的唯一真正的區別是,從瀏覽器運行時,包含access_token參數,從瀏覽器運行而不返回任何內容。
認證:
我使用的是這裏列出的OAuth認證:Mobile Apps - Getting Started 我需要包括在參數列表中做的access_token查詢時?
驗證碼:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
facebook = [[Facebook alloc] initWithAppId:@"<myAppId>"];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![facebook isSessionValid]) {
[facebook authorize:nil delegate:self];
}
NSArray* permissions = [[NSArray arrayWithObjects:
@"email", @"read_stream", nil] retain];
[facebook authorize:permissions delegate:self];
NSString *fql = [NSString stringWithFormat:@"SELECT aid FROM album WHERE owner=me()"];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:fql, @"query", @"json", @"format", nil];
[facebook requestWithMethodName:@"fql.query" andParams:params andHttpMethod:@"GET" andDelegate:self];
return YES;
}
- (void)request:(FBRequest *)request didLoad:(id)result {
if ([result isKindOfClass:[NSArray class]]) {
result = [result objectAtIndex:0]; }
NSLog(@"didLoad() received result: %@", result);
}
謝謝傑夫,不得不根據你的回答改變幾件事情。我已經添加了user_photos權限。 '的NSArray *權限= [[NSArray的arrayWithObjects: \t \t \t \t \t \t \t @ 「電子郵件」,@ 「read_stream」,@ 「user_photos」,零]保留];'和的access_token paramater'的NSMutableDictionary * PARAMS = [的NSMutableDictionary dictionaryWithObjectsAndKeys:fql,@「query」,@「json」,@「format」,facebook.accessToken,@「access_token」,nil];' – Allfocus