I searched everywhere and I cannot find documentation on how to post a story on Facebook in Swift. I tried to translate this code from Obj-C to Swift, but I didn't make much progress (I don't know how to code in Obj-C). I want to do something similar in Swift: https://developers.facebook.com/docs/ios/graph#postingstory
Here is the relevant code:
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:_objectID forKey:@"object"];
[FBRequestConnection startForPostWithGraphPath:@"me/og.likes"
graphObject:action
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
__block NSString *alertText;
__block NSString *alertTitle;
if (!error) {
NSLog(@"Posted OG action, id: %@", [result objectForKey:@"id"]);
alertText = [NSString stringWithFormat:@"Posted OG action, id: %@", [result objectForKey:@"id"]];
alertTitle = @"Success";
[[[UIAlertView alloc] initWithTitle:alertTitle
message:alertText
delegate:self
cancelButtonTitle:@"OK!"
otherButtonTitles:nil] show];
} else {
}
}];
Essentially, I'm looking for a Swift translation of this piece of code. In my actual application, I am going to post a high score for the game (I do not like the restaurant), but I should be able to understand this if I have Swift to work.
Thanks in advance!
source
share