views:

340

answers:

1

Hi

I want to connect facebook API's with my IPhone. For this I have downloaded the FBConnect sdk and included the FBConnect group of FBConnect.xcodeproj in my application and then I have written the following code in FacebookAPPViewController.m

- (void)viewDidLoad{

[super viewDidLoad];

session = [FBSession sessionForApplication:@"a31c3e53bba4a5f2b3955d6e5e 876717" secret:@"6ecbefa3807406bd13187297e58efae9" delegate:self];

FBLoginButton *button = [[[FBLoginButton alloc] init] autorelease];
[self.view addSubview:button];

FBLoginDialog* dialog = [[[FBLoginDialog alloc] init] autorelease];
[dialog show];
}

but it is showing error that session undeclared. That is right also because I have not initialized it but if I declare it with class FBSession then also It displays some error and if I exclude this line then the button to connect to facebook does not appear.

Can some one help me?

Thanks in advance

Gaurav

A: 

After setting up the session, you should pass it to the login dialog:

FBSession *session = [FBSession 
             sessionForApplication:@"a31c3e53bba4a5f2b3955d6e5e 876717"
             secret:@"6ecbefa3807406bd13187297e58efae9" delegate:self];

FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:session] autorelease];

[dialog show];

In your example, you're opening the login dialog right away, so there's no need to add a login button to your view.

PS. I hope you didn't use your real secret key in your code sample...

Philippe Leybaert