开发者

To display permission page in facebook of iphone

I am new to iphone development, i want to display the permission page after logging facebook.

buttonIndex is the index of my actionsheets.

 if(buttonIndex == 1)
 {  
    session = [FBSession sessionFor开发者_StackOverflow中文版Application:@"My App key" secret:@"My Key"   delegate:self];
FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:session] autorelease];
    [dialog show];  

 } 

by using those code successfully loggin to facebook, but i want to permission page to display,

so i can use,

 - (void)session:(FBSession*)session didLogin:(FBUID)uid 
 {

NSLog(@"User with id %lld logged in.", uid);

 FBPermissionDialog* dialog1 = [[[FBPermissionDialog alloc] init] autorelease];
 dialog1.delegate = self;
 dialog1.permission = @"uid";
 [dialog1 show];

 }

But its not working. Where can i put that code. And I want to share my content after the permission allowed.

If i logout the facebook, it goes to the browser but i want to return my application after logout,

Please help me out, guide me plz.


I would change this dialog1.permission = @"uid"; to something like this dialog1.permission = @"publish_stream";. Because you want to publish your content to the users stream, right?

 - (void)session:(FBSession*)session didLogin:(FBUID)uid

After loggin in I would first check if you might already have the permission to publish to the user's stream, by creating a FBRequest

NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: @"publish_stream", @"ext_perm", nil];
[[FBRequest requestWithDelegate:self] call:@"facebook.users.hasAppPermission" params:params];

The result you can evaluate here

- (void)request:(FBRequest*)request didLoad:(id)result 

e.g. like this

if ([request.method isEqualToString:@"facebook.users.hasAppPermission"])
{
    NSString *success = result;

    if ([success isEqualToString:@"1"]) 
    {
        NSLog(@"User has app permission");

        // publish content now
                    ...
    } 
    else
    {   // else ask for permission, opening permission dialog
        ...
    }


I highly recommend this guy's tutorial, Brandon Treb, on integrating Facebook. He does a very thorough presentation and takes you line-by-line, so if it does not work, its a typo on your part. His tutorial got me up and running in less than two hours.

http://brandontreb.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜