iphone - Intigration With Facebook in iOS using facebook sdk -
i trying post image in imageview(display_image) on user's profile using facebook sdk.code below.
fblinkshareparams *params = [[fblinkshareparams alloc] init]; params.link = [nsurl urlwithstring:@"https://developers.facebook.com/docs/ios/share/"]; // if facebook app installed , can present share dialog if ([fbdialogs canpresentsharedialogwithparams:params]) { // present share dialog [fbdialogs presentsharedialogwithlink:params.link handler:^(fbappcall *call, nsdictionary *results, nserror *error) { if(error) { // error occurred, need handle error // see: https://developers.facebook.com/docs/ios/errors nslog(@"error publishing story: %@", error.description); } else { // success nslog(@"result %@", results); } }]; // if facebook app not installed , can't present share dialog } else { nsmutabledictionary *params = [nsmutabledictionary dictionarywithobjectsandkeys:image_display.image, @"picture", @"hello",@"caption",nil]; [fbwebdialogs presentfeeddialogmodallywithsession:nil parameters:params handler:^(fbwebdialogresult result, nsurl *resulturl, nserror *error) { if (error) { // error occurred, need handle error // see: https://developers.facebook.com/docs/ios/errors nslog(@"error publishing story: %@", error.description); } else { if (result == fbwebdialogresultdialognotcompleted) { // user canceled. nslog(@"user cancelled."); } else { // handle publish feed callback nsdictionary *urlparams = [self parseurlparams:[resulturl query]]; if (![urlparams valueforkey:@"post_id"]) { // user canceled. nslog(@"user cancelled."); } else { // user clicked share button nsstring *result = [nsstring stringwithformat: @"posted story, id: %@", [urlparams valueforkey:@"post_id"]]; nslog(@"result %@", result); } } } }]; }
it's working out sending image value in params dictionary. using image app crash here below error
reason: '-[uiimage length]: unrecognized selector sent instance 0x7fdd5a80e160'
can 1 me solve problem?
thanks
you cannot post image can post image url example:-
-(void)fbshare{ // if facebook app installed , can present share dialog if ([fbdialogs canpresentsharedialog]) { nsurl *imageurl = [nsurl urlwithstring:@"https://profile_vmghbtjvm5_1413618023060.jpg"]; [fbdialogs presentsharedialogwithlink:[nsurl urlwithstring:@"http://www.testinfo.com/"] name:@"name related link" caption:nil description:@"testing desc" picture:imageurl clientstate:nil handler:^(fbappcall *call, nsdictionary *results, nserror *error) { if(error) { // error occurred, need handle error // see: https://developers.facebook.com/docs/ios/errors nslog(@"error publishing story: %@", error.description); } else { // success nslog(@"result %@", results); } }]; // if facebook app not installed , can't present share dialog } else { // fallback: publish link using feed dialog // put dialog parameters nsmutabledictionary *params = [nsmutabledictionary dictionarywithobjectsandkeys: @"testing name", @"name", @"testing caption.", @"caption", @"desc.", @"description", @"http://www.testinfo.com/", @"link", @"https://profile_vmghbtjvm5_1413618023060.jpg", @"picture", nil]; // show feed dialog [fbwebdialogs presentfeeddialogmodallywithsession:nil parameters:params handler:^(fbwebdialogresult result, nsurl *resulturl, nserror *error) { if (error) { // error occurred, need handle error // see: https://developers.facebook.com/docs/ios/errors nslog(@"error publishing story: %@", error.description); } else { if (result == fbwebdialogresultdialognotcompleted) { // user canceled. nslog(@"user cancelled."); } else { // handle publish feed callback nsdictionary *urlparams = [self parseurlparams:[resulturl query]]; if (![urlparams valueforkey:@"post_id"]) { // user canceled. nslog(@"user cancelled."); } else { // user clicked share button nsstring *result = [nsstring stringwithformat: @"posted story, id: %@", [urlparams valueforkey:@"post_id"]]; nslog(@"result %@", result); } } } }]; } }
Comments
Post a Comment