gpt4 book ai didi

iphone - 如何在 Objective C 中将好友标记为 Facebook 中的用户帖子

转载 作者:行者123 更新时间:2023-11-29 03:59:52 24 4
gpt4 key购买 nike

我正在尝试使用 Facebook Feed Dialog 发布文本和图像,我可以发布到我自己的墙上,但无法标记 friend 。我可以从 FBFriendPickerViewController 选择一个 friend ,但是当我单击完成时,我收到返回错误 5 。在 stackoverflow 的一个问题(ios-Facebook SDK 3.0 Error 5 When Posting Status Update)中,有几种方法可以导致此错误,我已经纠正了该问题中提到的所有可能的方法。

提要对话框是否正确 [FBRequestConnection startWithGraphPath:@"%@/feed"参数:params

这是我的代码,

- (IBAction)pickFriendsList:(UIButton *)sender
{
FBFriendPickerViewController *friendPickerController = [[FBFriendPickerViewController alloc] init];
friendPickerController.title = @"Pick Friends";
[friendPickerController loadData];

[friendPickerController presentModallyFromViewController:self animated:YES handler:
^(FBViewController *sender, BOOL donePressed) {

if (!donePressed) {
return;
}

NSString* fid;
NSString* fbUserName;

for (id<FBGraphUser> user in friendPickerController.selection)
{
NSLog(@"\nuser=%@\n", user);
fid = user.id;

fbUserName = user.name;

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"aaaaaa", @"message", @"http://webecoist.momtastic.com/wp-content/uploads/2009/01/nature-wonders.jpg", @"picture", @"My Susfsdfsdfs sdf sfsdfp", @"name", nil];

NSLog(@"\nparams=%@\n", params);


[FBRequestConnection startWithGraphPath:@"%@/feed" parameters:params HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error)


{
//Tell the user that it worked.
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Shared"
message:[NSString stringWithFormat:@"Invited %@! error=%@", fbUserName, error]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];

[alertView show];
NSLog(@"%@ alertview description",alertView.message);

}
];

}

}];

}

enter image description here enter image description here enter image description here enter image description here

错误:

> Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be
> completed. (com.facebook.sdk error 5.)" UserInfo=0xa157bf0
> {com.facebook.sdk:HTTPStatusCode=500,
> com.facebook.sdk:ParsedJSONResponseKey={
> body = {
> error = {
> code = 1;
> message = "An unknown error has occurred.";
> type = OAuthException;
> };
> };
> code = 500; }, com.facebook.sdk:ErrorSessionKey=<FBSession: 0x9491490, state: FBSessionStateOpen, loginHandler: 0x946f8d0, appID:
> 511223775602729, urlSchemeSuffix: ,
> tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x948f2b0>,
> expirationDate: 2013-06-15 05:04:17 +0000, refreshDate: 2013-04-16
> 10:36:11 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000,
> permissions:( )>}

最佳答案

注意:您的代码中缺少 FB 用户 ID

更改您的代码如下:

[FBRequestConnection
startWithGraphPath:[NSString stringWithFormat:@"%@/feed", fid]
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *)

问候,

关于iphone - 如何在 Objective C 中将好友标记为 Facebook 中的用户帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16009090/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com