【发布时间】:2012-02-11 07:51:06
【问题描述】:
我想分享我的应用程序详细信息。我刚刚完成了与 facebook 教程中相同的操作。当用户登录并出现对话框页面时,我发布了我的 msg。它仅在第一次运行良好。当用户点击按钮时再次分享,对话框出现并显示错误页面
"Error occurred with 'Your_APP_NAME'.please try again later."
我按照下面 facebook 链接中的教程进行操作。 https://developers.facebook.com/docs/mobile/ios/build/
这是我的代码。
-(void)buttonPressed:(id)sender{
facebook = [[Facebook alloc] initWithAppId:@"YOUR_APP_ID" andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]) {
facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![facebook isSessionValid]) {
[facebook authorize:nil];
}else{
[self postWall];
}
// Pre 4.2 support
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [facebook handleOpenURL:url];
}
- (void)fbDidLogin {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
[self postWall];
}
-(void)postWall{
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId,@"app_id",
@"https://developers.facebook.com/docs/reference/dialogs/",@"link",
@"http://fbrell.com/f8.jpg",@"picture",
@"Facebook Dialogs",@"name",
@"Reference Documentation",@"caption",
@"Using Dialogs to interact with users.",@"description",
@"Facebook Dialogs are so easy!",@"message",
nil];
[[self facebook] dialog:@"feed" andParams:params andDelegate:self];
}
我在我的视图控制器文件中执行所有这些代码(不在应用程序委托中)。我只想在按下按钮时打开 facebook。所以我将这些编码放在我的 buttonpressed 方法中。
【问题讨论】:
-
请贴一些代码,没有足够的细节
-
@Hanon 我检查了 facebook API 的流程..我认为我在 shouldStartLoadWithRequest: in FBDialog 文件中遇到错误..在该代码中检查 URL 方案“如果循环”没有作为“fbconnect”传递,而是像“https”一样传递。
标签: iphone objective-c ios facebook facebook-graph-api