0

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. :)

GangstaGraham
  • 8,865
  • 12
  • 42
  • 60

3 Answers3

3

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.

Reno Jones
  • 1,979
  • 1
  • 18
  • 30
  • This code does not work for me for some reason. Output: Error: HTTP status code: 400 result(null) – GangstaGraham Feb 21 '13 at 20:34
  • Actually I found out how to get it to work - I put it in the openSession method. Congratulations! Here, please reward yourself to a chocolate chip cookie! – GangstaGraham Feb 21 '13 at 20:51
  • Actually this method is still glitchy, do you know why it is so glitchy - it work only 70% of the time, that really isn't good enough. :( I know it's not ur fault, it's FB's but is there a way to get 100% accuracy. – GangstaGraham Feb 21 '13 at 22:29
  • If Graph is not working alright for you then try to read about 'FQL' and FBRequests with FQL. – Reno Jones Feb 22 '13 at 04:04
  • it is working fine but, data is nil ,data = ( ); – Vineesh TP Sep 29 '14 at 08:41
2

Add the following line after adding the request:

[conn start];
Beau Hankins
  • 103
  • 1
  • 8
0
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 ->

Neeku
  • 3,646
  • 8
  • 33
  • 43
UA_PPS
  • 29
  • 9