xcode6 - is there any way to share on facebook without showing the share dialog box in ios -
here code getting invalid publish_streem
. there way share on facebook without showing share dialog box in ios?
acaccountstore *accountstore = [[acaccountstore alloc] init]; acaccounttype *facebookaccounttype = [accountstore accounttypewithaccounttypeidentifier:acaccounttypeidentifierfacebook]; //acaccount *facebookaccount; // specify app id , permissions nsdictionary *options = @{acfacebookappidkey:@"565048226932112",acfacebookpermissionskey:@[@"publish_stream", @"publish_actions"],acfacebookaudiencekey:acfacebookaudiencefriends}; [accountstore requestaccesstoaccountswithtype:facebookaccounttype options:options completion:^(bool granted, nserror *error) { if (granted) { nsarray *accounts = [accountstore accountswithaccounttype:facebookaccounttype]; } else{ uialertview *alert = [[uialertview alloc] initwithtitle:@"error" message:[nsstring stringwithformat:@"%@",error] delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil, nil]; [alert show]; // nslog(@"error :%@",error); } }];
use facebook graph api
https://developers.facebook.com/docs/graph-api/reference/v2.2/post
reference : https://developers.facebook.com/docs/ios/share
// note: pre-filling fields associated facebook posts, // unless user manually generated content earlier in workflow of app, // can against platform policies: https://developers.facebook.com/policy
// put dialog parameters
nsmutabledictionary *params = [nsmutabledictionary dictionarywithobjectsandkeys: @"sharing tutorial", @"name", @"build great social apps , more installs.", @"caption", @"allow users share stories on facebook app using ios sdk.", @"description", @"https://developers.facebook.com/docs/ios/share/", @"link", @"http://i.imgur.com/g3qc1hn.png", @"picture", nil]; // make request [fbrequestconnection startwithgraphpath:@"/me/feed" parameters:params httpmethod:@"post" completionhandler:^(fbrequestconnection *connection, id result, nserror *error) { if (!error) { // link posted facebook nslog(@"result: %@", result); } else { // error occurred, need handle error // see: https://developers.facebook.com/docs/ios/errors nslog(@"%@", error.description); } }];
Comments
Post a Comment