I am getting an issue while posting a feed on Facebook using Facebook sdk in ios7.
I have copied the code from Facebook samples provided on Github. But whenever I tried to post on Facebook, a message appears as "An error occurred. Please try again later". And then I have to close the web view. Please find the code below: NSMutableDictionary *params123 = [NSMutableDictionary dictionaryWithObjectsAndKeys: @"Roasted pumpkin seeds", @"name", @"Healthy snack.", @"caption", @"Crunchy pumpkin seeds roasted in butter and lightly salted.", @"description", @" http://example.com/roasted_pumpkin_seeds ", @"link", @" http://i.imgur.com/g3Qc1HN.png ", @"picture", nil];
// Show the feed dialog
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params123
handler:^(FBWebDialogResult result, NSURL *resultURL, 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 {
if (result == FBWebDialogResultDialogNotCompleted) {
// User cancelled.
NSLog(@"User cancelled.");
} else {
// Handle the publish feed callback
NSDictionary *urlParams = [self parseURLParams:[resultURL query]];
if (![urlParams valueForKey:@"post_id"]) {
// User cancelled.
NSLog(@"User cancelled.");
} else {
// User clicked the Share button
NSString *result = [NSString stringWithFormat: @"Posted story, id: %@", [urlParams valueForKey:@"post_id"]];
NSLog(@"result %@", result);
}
}
}
}];
}
Note: I am using the updated version of Facebook sdk for iOS 7
Why do you use a webdialog ?
Here is what I use
NSArray *urlsArray = [NSArray arrayWithObjects:@"myurl1", nil];
NSURL *imageURL = [NSURL URLWithString:@"http://url/to/image.png"];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *image = [UIImage imageWithData:imageData];
NSArray *imagesArray = [NSArray arrayWithObjects:image, nil];
[FBDialogs presentOSIntegratedShareDialogModallyFrom:self
session:nil
initialText:@"My message for facebook"
images:imagesArray
urls:urlsArray
handler:^(FBOSIntegratedShareDialogResult result, NSError *error) {
NSLog(@"Result : %u", result);
if (error != nil) {
NSLog(@"Error : %@", [error localizedDescription]);
}
}];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.