到目前为止,这是我的代码,用本地图像发布自定义故事。图像显示在共享对话框中,但帖子没有完成。
NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPost];
object.provisionedForPost = YES;
object[@"title"] = @"";
object[@"type"] = @"socialsnooker:game_of_snooker";
object[@"description"] = @"";
object[@"url"] = @"http://socialsnooker.com/opengraph.php";
object[@"image"] = @[@{@"url": newImage, @"user_generated" : @"false" }];
NSArray* images = @[@{@"url": newImage, @"user_generated" : @"true" }];
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:images forKey:@"image"];
[action setObject:object forKey:@"game_of_snooker"];
[action setTags:@[opponent]];
// Tag a place using the place's id
id<FBGraphPlace> place = (id<FBGraphPlace>)[FBGraphObject graphObject];
[place setObjectID:@"36397646443"]; // Q-Masters
[action setPlace:place];
// Check if the Facebook app is installed and we can present the share dialog
FBOpenGraphActionParams *params = [[FBOpenGraphActionParams alloc] init];
params.action = action;
params.actionType = @"socialsnooker:score";
// If the Facebook app is installed and we can present the share dialog
if([FBDialogs canPresentShareDialogWithOpenGraphActionParams:params]) {
// Show the share dialog
[FBDialogs presentShareDialogWithOpenGraphAction:action
actionType:@"socialsnooker:score"
previewPropertyName:@"game_of_snooker"
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(@"Error publishing story: %@", error.description);
} else {
// Success
NSLog(@"result %@", results);
}
}];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"App Not Installed"
message:@"The Facebook App couldn't be found on your phone."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
Here is a Screenshot of the Share Dialog
图片确实显示在分享对话框中,我确实收到了帖子ID,但该动作未在Facebook上发布。
非常感谢任何帮助。感谢。