Facebook Graph GET请求

时间:2015-10-11 21:37:14

标签: ios objective-c facebook parse-platform

我的应用在向端点我的Facebook API发出GET请求时收到错误。

这是我的代码:

-(void) updateUserInformation{
    FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:@"/me:" parameters:@{@"fields": @"id, name, email, user_birthday"}];

    [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
        if(!error){
            NSDictionary *userDictionary = (NSDictionary *)result;
            NSMutableDictionary *userProfile = [[NSMutableDictionary alloc] initWithCapacity:8];

            if (userDictionary[@"name"]) {
                userProfile[@"name"] = userDictionary[@"name"];
            }

            if (userDictionary[@"first_name"]) {
                userProfile[@"first_name"] = userDictionary[@"first_name"];
            }

            if (userDictionary[@"location"][@"name"]) {
                userProfile[@"location"] = userDictionary[@"location"][@"name"];
            }

            if (userDictionary[@"gender"]) {
                userProfile[@"gender"] = userDictionary[@"gender"];
            }

            if (userDictionary[@"birthday"]) {
                userProfile[@"birthday"] = userDictionary[@"birthday"];
            }
            if (userDictionary[@"interested_in"]) {
                userProfile[@"interested_in"] = userDictionary[@"interested_in"];
            }

            [[PFUser currentUser] setObject:userProfile forKey:@"profile"];

            [[PFUser currentUser] saveInBackground];

        }else {
            NSLog(@"Error in Facebook Request %@", error);
        }

    }];
}

我得到的错误是:

2015-10-11 14:30:59.306 MatchedUp[2358:139193] Error in Facebook Request Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=803, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
    body =     {
        error =         {
            code = 803;
            "fbtrace_id" = "CfGbwnx4/B9";
            message = "(#803) Some of the aliases you requested do not exist: me:";
            type = OAuthException;
        };
    };
    code = 404;
}, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=404, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=(#803) Some of the aliases you requested do not exist: me:, com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0}

我不太清楚这个错误意味着什么。它说“你请求的一些别名不存在:me:”这是否意味着completionHandler中的结果字典不包含端点的一些信息?任何帮助,将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:1)

尝试将图表路径@"/me:"更改为@"me"

祝你好运!