FBSDKGraphRequest给出了错误"不支持的URL"同时获取活动出席名单Facebook iOS

时间:2015-08-13 12:04:58

标签: ios iphone facebook facebook-graph-api

我将通过此代码参加活动列表。

NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                [[[FBSession activeSession] accessTokenData] accessToken], @"access token",
                                @"100000000000",@"limit",
                                nil];

FBSDKGraphRequest *requestA = [[FBSDKGraphRequest alloc] initWithGraphPath:[NSString stringWithFormat:@"%@/attending",[self.dictData objectForKey:@"FBEventId"]] parameters:params HTTPMethod:@"GET"];
        FBSDKGraphRequestConnection *connectionA = [[FBSDKGraphRequestConnection alloc] init];
        [connectionA addRequest:requestA completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

            if(!error)
            {
                attending = [[result objectForKey:@"data"] count];
                [tblDetail reloadData];
            }
            else
            {
                attending = 0;
                NSLog(@"error description : %@",error.description);
            }
        }];
        [connectionA start];

这很好用。但如果我再次打电话给它,它会给我错误,

好像,它只工作一次。

Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo=0x7fe846142280 {NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x7fe843ddcb90 "unsupported URL"}

我可以访问这些权限,

Permission : (
    "user_events",
    "user_friends",
    "rsvp_event",
    email,
    "publish_actions",
    "public_profile"
)

这样做是否足够? 为什么会发生这种情况?

1 个答案:

答案 0 :(得分:0)

最后我得到了解决方案。实际问题出在我的图表请求中。

这是一个正确的。

    NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                    @"100000000000",@"limit",
                                    nil];

        FBSDKGraphRequest *requestA = [[FBSDKGraphRequest alloc] initWithGraphPath:[NSString stringWithFormat:@"%@/attending",[self.dictData objectForKey:@"FBEventId"]] parameters:params tokenString:[[[FBSession activeSession] accessTokenData] accessToken] version:@"v2.3" HTTPMethod:self.HTTPGet];
    FBSDKGraphRequestConnection *connectionA = [[FBSDKGraphRequestConnection alloc] init];
    [connectionA addRequest:requestA completionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {

        if(!error)
        {
            attending = [[result objectForKey:@"data"] count];
        }
        else
        {
            attending = 0;
            NSLog(@"error description : %@",error.description);
        }
        [tblDetail reloadRowsAtIndexPaths:[NSArray arrayWithObjects:[NSIndexPath indexPathForRow:3 inSection:0], nil] withRowAnimation:UITableViewRowAnimationAutomatic];

    }];
    [connectionA start];