我使用以下代码在fb时间轴上使用FBSDK开放图形对象和FBSDK打开图形内容共享图片和一些消息。但是,以下代码什么都不做,没有提供对话框,也没有向时间轴发布任何内容.am我在这段代码中遗漏了什么,或者这段代码在模拟器中不起作用?
- (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];
}
在委托方法
中-(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}
答案 0 :(得分:3)
将[action setPhoto:photo forKey:@"image"];
更改为[object setPhoto:photo forKey:@"og:image"];
答案 1 :(得分:0)
2:fatuhoku - 感谢您的评论。你是对的 - 我正在使用FBSDKShareAPI。如果我在userGenerated设置为YES的情况下创建照片,则会像照片一样附加。照片放在我的相册(自动创建)中,其中包含我的应用程序名称,帖子类型为“照片”。如果我使用userGenerated设置为NO将照片放置在内部FB阶段,则帖子是“链接”类型,但我可以通过更改图片URL中的两个参数w = 130来提取帖子属性“图片”中的照片并通过一些技巧h = 130得到我照片的必要尺寸。所有这些我使用API而不是Dialogs。