我需要发布行动
我成功发布了图表API中的“喜欢链接”。 例如'abc喜欢www.abc.com'
现在我被困在'喜欢自定义对象',例如'abc likes toy1' 并获得喜欢的总数。
这是不起作用的示例代码
NSDictionary *properties = @{
@"og:type": @"toy",
@"og:title": @"toy1",
@"og:description": @"This is a sample course."};
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = @"og.likes";
[action setObject:object forKey:@"toy"];
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"toy";
FBSDKShareAPI *shareAPI = [[FBSDKShareAPI alloc] init];
// optionally set the delegate
shareAPI.delegate = self;
shareAPI.shareContent = content;
[shareAPI share];
编辑:我的代码正在改变
toy
到
appnamespace:toy
和
[action setObject:object forKey:@"toy"]; // to [action setObject:object forKey:@"object"];
现在我想获取此自定义对象上的总喜欢次数
答案 0 :(得分:0)
A" og:type" "玩具"无效。它应该是一个常见的OG类型(如" fitness.course")或自定义的(#34; yourappnamespace:玩具")。
如果您只是喜欢网站或其他网址,则可以跳过OG对象并创建
之类的操作FBSDKShareOpenGraphAction *action = [FBSDKShareOpenGraphAction actionWithType:@"og.likes" objectURL:[NSURL URLWithString:@"http://www.example.com"] key:@"og:object"];
(请注意,如果你尝试两次相同的东西,它会给你一个错误。)
您应该确保您的委托实现- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
以接收错误信息。