问题
Nothing gets printed out in the console, and I don't get any info while using a - (void)request:(FBRequest *)request didLoad:(id)result
either
Basically I would like the user's name, FB username, and FB id. Is there any other way to get this info, since this method does not seem to be working.
- (IBAction)performLogin:(id)sender
{
[self.spinner startAnimating];
GIFAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
[appDelegate openSession];
FBRequestConnection* conn = [[FBRequestConnection alloc] init];
[conn addRequest:[FBRequest requestForMe] completionHandler:^(FBRequestConnection *connection, NSDictionary<FBGraphUser> *me, NSError *error) {
if(error) {
NSLog(@"Error requesting user info");
return;
}
NSLog(@"User's name is %@", me.name);
}];
}
Note that the rest of the method works, just not the FBRequestConnection portion of it. :)
回答1:
I believe you have just started using the new graph SDK:
Here is how you can pull out some of the info:
// Your Info:
[FBRequestConnection startWithGraphPath:@"/me" parameters:nil HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(@"result %@",result);
}];
// Your Friends Info
[FBRequestConnection startWithGraphPath:@"me/friends" parameters:nil HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSLog(@"result %@",result);
}];
And similarly, you can pull out more information. You should read about more graph objects - here. This is how you will get to know, what all things you can pull out. Also you can query on facebook using FQL.
Hope this helps.
回答2:
Add the following line after adding the request:
[conn start];
回答3:
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[NSString stringWithFormat:@"%ld", (long)10], @"score",
nil];
dispatch_queue_t some_queue = dispatch_queue_create("some.queue.name", NULL);
dispatch_async(some_queue, ^{
// [NSString stringWithFormat:@"%llu/scores", lintFBFriendId]
[FBRequestConnection startWithGraphPath:@"APP_ID/scores"
parameters:params
HTTPMethod:@"GET"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
NSLog(@"result->%@");
}
}];
I wanna Fetch Scores but when i put [FBRequestConnection startWithGraphPath:
in a queue but it doesn't response or print data if i remove queue it works
code ->
来源:https://stackoverflow.com/questions/15011138/fbrequestconnection-not-working