gpt4 book ai didi

ios - 在单个墙贴中将带有状态消息的多张照片发布到 Facebook

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:09:34 25 4
gpt4 key购买 nike

我无法像这张图片那样发布。所有图像和多个图像的通用标题。至少,告诉我它是否可能

enter image description here

我尝试遍历所有图像并成功发布所有图像,但没有获得标题。 (在图片中是:“测试:请忽略 FRNDS。”)。我该怎么做?

我的代码发布成功,但问题是每张照片都是不同的帖子。我希望所有照片都放在一个帖子中。

这是我尝试过的:

    NSMutableArray *arrayOfImages = [self getSelectedImagesArray];
for (int i=0; i<arrayOfImages.count; i++)
{
NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
[params setObject:@"LOL !! THIS IS IMAGE" forKey:@"message"];
//[params setObject:@"LOL !! APP NAME" forKey:@"name"];
[params setObject:@"LOL !! THIS IS IMAGE CAPTION" forKey:@"caption"];
[params setObject:@"LOL !! THIS IS IMAGE description" forKey:@"description"];
[params setObject:UIImageJPEGRepresentation([arrayOfImages objectAtIndex:i], 0.5) forKey:@"picture"];

[FBRequestConnection startWithGraphPath:@"me/photos"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error)
{
NSString *alertText;

if (error)
{
//showing an alert for failure
[[FBSession activeSession] openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session, FBSessionState status, NSError *error)
{
[self shareAdvertOnFacebook];
}];
alertText = [NSString stringWithFormat: @"error: domain = %@, code = %d", error.domain, error.code];
}
else
{
//showing an alert for success
alertText = [NSString stringWithFormat: @"Posted action, id: %@", result[@"id"]];
[[[UIAlertView alloc] initWithTitle:@"Result" message:@"Advert is posted to Facebook successfully." delegate:self cancelButtonTitle:@"OK!" otherButtonTitles:nil] show];
}
}];
}

最佳答案

首先确保您拥有创建新专辑的 publish_stream 权限。然后创建一个新相册,调用 Graph API 到 https://graph.facebook.com/me/albums带有访问 token 、相册名称和相册描述的参数。

如果相册创建成功,将返回新的相册ID。然后调用https://graph.facebook.com/NEW_ALBUM_ID/photos使用访问 token 和其他照片参数将您的照片上传到新相册。

默认情况下,如果您不指定任何相册而只是将照片推送到 me/photos 端点,您的照片最终将位于为您的应用程序自动创建的相册中。

此代码对我有用,只需将代码添加到“发布所有图片”

- (void) postImageToFB:(UIImage*)image
{
NSData* imageData = UIImageJPEGRepresentation(image, 90);
NSString *text=@"Purchased a book From Library Store,\nBook Name-";
text=[text stringByAppendingString:lbl_bk_name.text];
text=[text stringByAppendingString:@"\nCategory-"];
text=[text stringByAppendingString:lbl_bk_category.text];
text=[text stringByAppendingString:@"\nFeeling Great!!"];


NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
text, @"message",
imageData, @"source",
nil];

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


if (error) {
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Facebook" message:@"Problem in sharing in Facebook. Try Later!" delegate:self cancelButtonTitle:@"OK"otherButtonTitles:nil, nil];
[alert show];
} else {


UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Facebook" message:@"Shared Successfully." delegate:self cancelButtonTitle:@"OK"otherButtonTitles:nil, nil];
[alert show];

}



}];
}

关于ios - 在单个墙贴中将带有状态消息的多张照片发布到 Facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20016222/

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