我创建了一个定义了标题的对象。发布后,我使用对象浏览器确认它的标题设置正确。尽管如此,动作显示的是名词,而不是标题(就好像对象没有定义标题)。
我期望看到:“报道Texaco的燃油价格”
我得到的结果:“在车站报告燃油价格”
我正在使用的代码:
- (void)postToFacebook
{
id<FBOpenGraphObject> graphObject = [FBGraphObject openGraphObjectForPost];
graphObject[@"title"] = @"My Title"
graphObject[@"type"] = @"myappnamespace:myobject";
graphObject[@"description"] = @"My Object Description";
graphObject[@"image"] = @[@{@"url": @"http://example.com", @"user_generated" : @"false"}];
graphObject[@"url"] = @"http://example.com";
[FBRequestConnection startForPostOpenGraphObject:graphObject
completionHandler:^(FBRequestConnection *connection, id result, NSError *error)
{
NSString *objectId = [result objectForKey:@"id"];
NSLog(@"Open Graph Object Posted: %@", objectId);
// create an Open Graph action
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:objectId forKey:@"myobject"];
[action setObject:@"true" forKey:@"fb:explicitly_shared"];
// create action referencing user owned object
[FBRequestConnection startForPostWithGraphPath:@"/me/myappnamespace:my_action" graphObject:action completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(!error) {
NSLog(@"Action successfully posted to facebook!");
} else {
// An error occurred
NSLog(@"Encountered an error posting to Open Graph: %@", error);
}
}];
}];
}