gpt4 book ai didi

ios - 使用 FBSDKShareDialog 在应用程序中共享 fb 图像和消息内容不起作用

转载 作者:可可西里 更新时间:2023-11-01 04:43:45 24 4
gpt4 key购买 nike

我正在使用以下代码使用 FBSDK 开放图形对象和 FBSDK 开放图形内容在 fb 时间轴上共享图片和一些消息。但是以下代码什么都不做,不显示对话框,也不向时间轴发布任何内容.我是否遗漏了这段代码中的任何内容,或者这段代码在模拟器中不起作用?

- (IBAction)shareButtonPressed:(id)sender {
NSString *contentDesc=@"abcdcccdcc";
NSString *title=[NSString stringWithFormat:@"%@ \n asd %@, asd %@",self.nameLabel.text,_fromDate.text,_toDate.text];

FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = _profilePic.image;
photo.userGenerated = YES;

// Create an object
NSDictionary *properties = @{
@"og:type": @"memories.memory",
@"og:title":title ,
@"og:description":contentDesc

};
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];

// Create an action
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = @"memories.view";
[action setObject:object forKey:@"memories.memory"];

// Add the photo to the action
[action setPhoto:photo forKey:@"image"];

// Create the content
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"memories.memory";

[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:nil];
}

在委托(delegate)方法中

-(void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{


NSLog(@"%@",error);
}

错误日志打印如下

Error Domain=com.facebook.sdk.share Code=2 "The operation couldn’t be completed. (com.facebook.sdk.share error 2.)" UserInfo=0x7faec97bb660 {com.facebook.sdk:FBSDKErrorArgumentValueKey=<FBSDKShareOpenGraphContent: 0x7faecbc16740>, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Feed share dialogs support FBSDKShareLinkContent., com.facebook.sdk:FBSDKErrorArgumentNameKey=shareContent}

最佳答案

[action setPhoto:photo forKey:@"image"]; 更改为 [object setPhoto:photo forKey:@"og:image"];

关于ios - 使用 FBSDKShareDialog 在应用程序中共享 fb 图像和消息内容不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29937102/

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