FBRequestConnection not working

血红的双手。 提交于 2019-12-12 03:46:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!