Die*_*nez 7 facebook ios facebook-ios-sdk
我正在将Facebook整合到我的应用程序中以共享网站链接.我正在使用Feed对话来完成此操作,我正在学习本教程:
https://developers.facebook.com/docs/howtos/feed-dialog-using-ios-sdk/.
我已设法登录并发布到Facebook,但我想在帖子成功时添加消息.本教程内置了这个,但每次发布时,我都会在日志中看到" 用户取消的故事发布. ",这是用户点击取消时显示的消息.除了我已经向调试器确认,resultURL即使在成功的帖子上,处理程序收到的参数总是为零.
起初我虽然这是我的配置问题Facebook App,但我决定进行测试.我打开了RPSSample随框架提供的内容,在视图控制器presentRequestsDialogModallyWithSession的clickInviteFriends方法中为调用添加了一个完成处理程序RPSFriendsViewController.m,我也在那里resultURL成功发布了一个nil .
我错过了什么?
我知道3.5 SDK版本是非常新的,但根据文档,我应该resultURL在通过Facebook Web对话框发布后得到一个有效的参数,所以我不确定它是否是一个错误或者我是否遗漏了某些回调或处理程序.
以防万一,这是我对Feed Web对话的调用.与教程中的内容相比,它有一些细微的变化(实际上更简单)
- (void)publish: (EntityToShare *)entityToShare {
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
entityToShare.link, @"link",
nil];
// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
// Error launching the dialog or publishing a story.
NSLog(@"Error publishing story.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
// User clicked the "x" icon
NSLog(@"User canceled story publishing.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:@"post_id"]) {
// User clicked the Cancel button
NSLog(@"User canceled story publishing.");
} else {
// User clicked the Share button
NSString *msg = [NSString stringWithFormat:
@"Posted story, id: %@",
[urlParams valueForKey:@"post_id"]];
NSLog(@"%@", msg);
// Show the result in an alert
[[[UIAlertView alloc] initWithTitle:@"Result"
message:msg
delegate:nil
cancelButtonTitle:@"OK!"
otherButtonTitles:nil]
show];
}
}
}
}];
}
Run Code Online (Sandbox Code Playgroud)