我使用以下代码在 Facebook 上发布,在Params字典中输入所有必需的详细信息并添加到 FBWebDialogs 中,但该帖子未显示在朋友墙中。
NSDictionary *params = @{
@"name" :[NSString stringWithFormat:@"%@",[Data_Dict objectForKey:@"name"]],
@"caption" : @"",
@"description" :[Data_Dict objectForKey:@"desc_title"],
@"picture" : str_link,
@"link" : @"",
};
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error)
{
//NSLog(@"Error publishing story.");
[self.indicator stopAnimating];
}
else
{
if (result == FBWebDialogResultDialogNotCompleted)
{
//NSLog(@"User canceled story publishing.");
}
else
{
//NSLog(@"Story published.");
}
}}];
}
}];
期待解决这个问题的想法。
答案 0 :(得分:3)
[FBSession openActiveSessionWithReadPermissions:nil allowLoginUI:YES completionHandler:^(FBSession *session,FBSessionState state, NSError *error)
{
if (error)
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
else if(session.isOpen)
{
//NSLog(@"%@",Data_Dict);
NSString *str_link = [NSString stringWithFormat:@"%@uploads/%@-5.jpg",app.Main_url,[Data_Dict objectForKey:@"deal_id"]];
//NSLog(@"%@",str_link);
NSDictionary *params = @{
@"name" :[NSString stringWithFormat:@"%@",[Data_Dict objectForKey:@"name"]],
@"caption" : @"",
@"description" :[Data_Dict objectForKey:@"desc_title"],
@"picture" : str_link,
@"link" : @"",
};
// Invoke the dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
//NSLog(@"Error publishing story.");
[self.indicator stopAnimating];
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
//NSLog(@"User canceled story publishing.");
[self.indicator stopAnimating];
} else {
//NSLog(@"Story published.");
[self.indicator stopAnimating];
}
}}];
}
}];
[self.indicator stopAnimating];
return;