Facebook iOS授权和发布没有对话框? [英] Facebook iOS Authorise and Post Without Dialog?

查看:114
本文介绍了Facebook iOS授权和发布没有对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用iOS SDK的Facebook SDK,并彻底检查了文档和其他帮助,但无法成功。

Im just starting out with the Facebook SDK for iOS and checked out the documentation and other help thoroughly but can't be successful.

我已经开始了一个新视图根据文档中的建议进行授权。每当我启动应用程序切换到Facebook应用程序(我已经安装在我的iPhone上),并说已经授权,按OK。我如何反复停止这样做?

I have started a new view based app and authorised just as recommended in the docs. Everytime I start the app its switches to the Facebook app (which I have installed on my iPhone) and says already authorised, press okay. How can I stop it repeatedly doing this?

我也尝试过发布到Facebook而没有对话。控制台告诉我一个请求,但是发生错误(不会崩溃但didFailWithError告诉我)。

I also have tried posting to Facebook without a dialog. The console tells me a request is made but then a error occurs (doesn't crash but the didFailWithError tells me).

无论如何,我没有发布任何我的代码因为它似乎相对简单,所以如果有人知道如何做到这一点,我会大力欣赏任何帮助,甚至可能代码示例。

Anyway I haven't posted any of my code as it seems relatively simple so if there is someone who knows how to do this I would massively appreciate any help, and possibly even a code sample.

谢谢。 >

Thanks.

推荐答案

您在代理中缺少关键点,您必须自己保存会话数据

You're missing a key point in your delegate, you have to save the session data yourself

- (void)fbDidLogin {
    // store the access token and expiration date to the user defaults
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:facebook.accessToken forKey:ACCESS_TOKEN_KEY];
    [defaults setObject:facebook.expirationDate forKey:EXPIRATION_DATE_KEY];
    [defaults synchronize];
}

然后当您初始化Facebook时,您将执行以下

And then when you initialize facebook you would do the following

facebook = [[Facebook alloc] initWithAppId:kAppId];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
facebook.accessToken = [defaults objectForKey:ACCESS_TOKEN_KEY];
facebook.expirationDate = [defaults objectForKey:EXPIRATION_DATE_KEY];

最后,如果你想发布没有对话框,你会这样做

And finally, if you want to post without a dialog you would do this

NSString *message = @"Visit my blog http://effectivemobility.blogspot.com/";
NSArray *obj = [NSArray arrayWithObjects:message, nil];
NSArray *keys = [NSArray arrayWithObjects:@"message", nil];

// There are many other params you can use, check the API
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjects:obj forKeys:keys];

[facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:nil];

我希望有帮助

这篇关于Facebook iOS授权和发布没有对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆