No results returned when doing Facebook Query
I'm trying to get a list of aid (album ids) using a Facebook Query.
What Works:
Running the query from the browser returns results, but when I run it using Facebook Connect no values are returned.
The problem I'm having is specific the album object, I get results when querying the user table.
The only real difference I can think of is when running from the browser a access_token parameter is included, running from browser without this returns nothing.
Authentication:
I am using OAuth to authenticate as outlined here: Mobile Apps - Getting Started Do I need to include the access_token in the parameter list when doing a query?
The Code:
- (BOOL)application:(UIApplication *)application didFinishLaun开发者_运维百科chingWithOptions:(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);
}
Yes, you absolutely need to include the access_token
field. We verify that the access token has access to the user_photos permission before allowing you access to that user's data.
精彩评论