facebook集成问题IOS

时间:2012-07-10 17:38:29

标签: iphone facebook

我正在尝试将facebook集成到我的iOS 5应用程序中。 正如在facebook文档中提到的,我正在做他们提到的一切。 通常当facebook被启动授权时,它将用户浏览器打开Facebook网站并要求进行身份验证。但就我而言,它会打开浏览器并立即返回应用程序。我不明白发生了什么。

它在Facebook上没有发布任何内容。它只是转换到本机应用程序,然后再回来。

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"] 
    && [defaults objectForKey:@"FBExpirationDateKey"]) 

{



    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   @"SELECT uid, name, pic, email FROM user WHERE uid=me()", @"query",nil];

    [facebook requestWithMethodName:@"fql.query"
                          andParams:params
                      andHttpMethod:@"POST"
                        andDelegate:self];

    facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
    facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];

    UIAlertView *alertView = [[UIAlertView alloc]
                              initWithTitle:@"Facebook"
                              message:@"You are successfully signed in."
                              delegate:nil
                              cancelButtonTitle:nil
                              otherButtonTitles:nil,
                              nil];
    [self performSelector:@selector(dismissAlertView:) withObject:alertView afterDelay:2];
    [alertView show];

    NSLog(@"signed in");
       }


if (![facebook isSessionValid]) {
    NSArray *permissions = [[NSArray alloc] initWithObjects:
                            @"user_likes", 
                            @"read_stream",
                            @"publish_stream",

                            nil];
    [facebook authorize:permissions];
    [permissions release];


}

else if([facebook isSessionValid]){        facebookOut.hidden = NO;

}

1 个答案:

答案 0 :(得分:0)

您是否尝试添加权限以供用户授权?与此类似的东西

   NSArray *permissions = [[NSArray alloc] initWithObjects:
        @"user_likes", 
        @"read_stream",
        nil];
   [facebook authorize:permissions];
   [permissions release];