gpt4 book ai didi

ios - FBWebDialogs 添加本地镜像到参数

转载 作者:行者123 更新时间:2023-11-29 12:47:40 24 4
gpt4 key购买 nike

请在下面找到我的代码分享到 friend 墙上

AppDelegate *appDelegate = [[UIApplication sharedApplication]delegate];
// if we don't have permission to announce, let's first address that
if ([appDelegate.session.permissions indexOfObject:@"publish_actions"] == NSNotFound)
{
NSArray *permissions =[NSArray arrayWithObjects:@"publish_actions",@"publish_stream",@"manage_friendlists", nil];

[FBSession setActiveSession:appDelegate.session];

[[FBSession activeSession] requestNewPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends
completionHandler:^(FBSession *session, NSError *error)
{
if (!error)
{
// have the permission
[self poster];
}
else
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:error.localizedDescription delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
}];
}
else
{
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
_friendId, @"to",
@"text change", @"caption",
@"Some Text", @"description",
@"http://example.com/pic.png", @"picture",
nil];
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:
^(FBWebDialogResult result, NSURL *resultURL, NSError *error)

{
//stuff
}];
}

这工作正常,但是当我尝试放置本地镜像而不是图片 url 时,应用程序崩溃

[UIImage imageNamed:@"troll.png"], @"picture"

最佳答案

如果您阅读 documentation -

picture: The URL of a picture attached to this post. The picture must be at least 200px by 200px.

因此,您不能将图像数据传递到 Feed - 只有指向该图片的链接才有效。

要解决这个问题,您只有两个选择-

  1. 将图片保存到服务器,并生成链接并将此链接传递给picture参数。

  2. 使用 \POST /photos将图片上传到facebook ,然后在 picture 参数中使用它的链接。 - 这不会工作检查“Edit-2”


编辑 1:获取图片链接-

[FBRequestConnection startWithGraphPath:@"/{photo-id}?fields=picture"
parameters:nil
HTTPMethod:@"GET"
completionHandler:^(
FBRequestConnection *connection,
id result,
NSError *error
) {
/* handle the result */
}];

(这可以忽略,因为 facebook cdn 图片不能在 picture 参数中使用。检查“Edit-2”)

编辑 2:

根据 facebook 人员的说法-

  1. object_attachment is not supported for feed dialogs.
  2. picture is the correct method to modify the image for your post. However, you can not specify an image from Facebook's CDN for this parameter.

所以我猜你只剩下一个选择 - 在 facebook 以外的其他服务器上上传照片,并在 picture 参数中使用该 url。

关于ios - FBWebDialogs 添加本地镜像到参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23239037/

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