如果您使用的是 iOS,您可以使用本机 FBWebDialogs 执行类似的操作,例如:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@"Some stand out message", @"name",
@"Some very short description of ?", @"description",
@"http://example.com/", @"link",
@"http://example.com/img/pic.png/", @"picture",
@"12345_friendID", @"to",
nil];;
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^
(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
NSLog(@"Error publishing story :%@", error);
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
NSLog(@"User cancelled publishing");
} else {
NSDictionary *urlParams = [self parseURLParams: [resultURL query]];
if (![urlParams valueForKey@"post_id"]) {
NSLog(@"User cancelled publishing");
} else {
NSLog(@"You published a story with id:%@", [urlParams valueForKey@"post_id"]);
}
}
}
}];
- (NSDictionary*)parseURLParams:(NSString *)query {
NSArray *pairs = [query componentsSeparatedByString:@"&"];
NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
for (NSString *pair in pairs) {
NSArray *kv = [pair componentsSeparatedByString:@"="];
NSString *val =
[[kv objectAtIndex:1]
stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[params setObject:val forKey:[kv objectAtIndex:0]];
}
return params;
}