Search code examples
objective-cfacebookfacebook-ios-sdk

IOS Facebook SDK can't get User info after log in


Alright, I am having a devil of a time with getting some basic user info from the Facebook IOS SDK (3.1.1). Having done FB development with other platforms I am pretty convinced my issue has to do with the FB app's set up than with my code. BTW, I am in iTunes and have set an iTunes ID for iPhone. I have also carefully checked and quadruple checked the bundle ID in the App set up against my bundle ID.

Right now I can authenticate with a test user and get all the detail, etc. It works great. When I log in as a real user like myself (and I am a developer on the project) I get an Auth token, but calls to get the user fail, and I'm not sure what I have done wrong (if it works for a test user it should work for everyone).

All I need to get from the user, BTW is their First name, Last name, FB User ID, and email address (optional, but requested).

Currently after authenticating using the I'm using the games tutorial. Once I am logged in I do the following (although I have done a bunch of other things with the same result):

 - (void)fbDidLogin
 {
    // removed the setup for the class level Facebook var that I am currently not using

    // get information about the currently logged in user

    NSString *fql = @"select uid, first_name, last_name, email  from user where uid = me()";
    NSDictionary *queryParam = [NSDictionary dictionaryWithObjectsAndKeys:fql, @"q", nil];

    [FBRequestConnection startWithGraphPath:@"/fql"
                      parameters:queryParam
                      HTTPMethod: @"GET"
                      completionHandler:^(FBRequestConnection *connection,
                                          id result,
                                          NSError *error) {
                        [self meRequestResult:result WithError:error];
                      }];
 }

The meRequestResult routine starts like this:

- (void)meRequestResult:(id)result WithError:(NSError *)error
{
 if ([result isKindOfClass:[NSDictionary class]])
 {
    NSDictionary *dictionary;
    if([result objectForKey:@"data"])
        dictionary = (NSDictionary *)[(NSArray *)[result objectForKey:@"data"] objectAtIndex:0];
    else
        dictionary = (NSDictionary *)result;

    [fbUserData release];
    fbUserData = [dictionary retain];

    NSString *facebookId = [dictionary objectForKey:@"id"];
    if(!facebookId)
        facebookId = [dictionary objectForKey:@"uid"];
 // and more follows that is not pertinent

When I turn on request logging in the FB IOS SDK. I see the same things and can not find any description anywhere what these mean.

Here's the last 10 or so lines from the log:

 2012-12-03 11:52:12.394 mTender[6572:1cd03] Reachability Flag Status: -R -----l- networkStatusForFlags
 2012-12-03 11:52:12.395 mTender[6572:1cd03] The internet is working via WIFI.
 2012-12-03 11:52:12.396 mTender[6572:1cd03] Reachability Flag Status: -R ------- networkStatusForFlags
 2012-12-03 11:52:12.396 mTender[6572:1cd03] A gateway to the host server is working via WIFI.
 2012-12-03 11:52:35.093 mTender[6572:1cd03] FBSDKLog: Request <#1111>:
      URL:  https://graph.facebook.com//fql?sdk=ios&access_token=ACCESS_TOKEN_REMOVED&q=select%20uid%2C%20first_name%2C%20last_name%2C%20email%20%20from%20user%20where%20uid%20%3D%20me%28%29&migration_bundle=fbsdk%3A20121003&format=json
      Method:   GET
      UserAgent:    FBiOSSDK.3.1.1
      MIME: multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f

 2012-12-03 11:52:37.194 mTender[6572:1cd03] Error: HTTP status code: 500
 2012-12-03 11:52:37.196 mTender[6572:1cd03] FBSDKLog: Response <#1111> <Error>:
     The operation couldn’t be completed. (com.facebook.sdk error 5.)

Hopefully someone can figure this out. It's the last step of this project..


Solution

  • OK, I'm going to close this out.

    I reverted to an SDK back in November of 2011. It didn't seem to be working at first, and then it just started working. I suspect a bug on Facebook's end was causing this. I haven't updated to the latest again to try, but this is my only guess as to what happened.

    If you've done any lengthy Facebook development you know that sometimes their bugs really make things difficult. That said, no idea if this is the actual answer since I really didn't make any coding changes from the original code.

    I know that I purposefully left the bundle ID out of the FB App Setup..