facebook - An open FBSession must be specified for calls to this endpoint in iOS -


i newbie in ios development. want upload image on facebook page.when image picked camera.for write code below got error "fbsession must specified calls endpoint". please give me solution it.

my code

-(ibaction)camerabuttonpressed:(id)sender  { if (fbsession.activesession.isopen) {     uiimage *uploadimage=[uiimage imagenamed:@"2.png"];     nsdictionary *params = [nsdictionary dictionarywithobjectsandkeys:accesstoken, @"caacedeose0cbaafij51qowoobfocobm1e3v1zbzcnybszayspbqcxpuzcdzc620brwyvchxgd96zaosmnyrza9tyd9teq9q1m67wkx0n66yjtiyzbxczkizb7t3tulo5rysnbzbfgwezcenmxrf7xobe6dq6450nmb0hrjzi8prt18wzafu878ghnryp5vw4up3jgzcwpwmumxdzaozaxvosyzbnkq6i",                             postingstring, @"message",uploadimage,@"source",                             nil];     fbrequest *requesttopost = [[fbrequest alloc] initwithsession:nil                                                         graphpath:@"/me/feed"                                                        parameters:params                                                        httpmethod:@"post"];     fbrequestconnection *requesttopostconnection = [[fbrequestconnection alloc] init];     [requesttopostconnection addrequest:requesttopost completionhandler:^(fbrequestconnection *connection, id result, nserror *error)      {          nslog(@"facebook result >> %@", result);      }];     [requesttopostconnection start]; } else {     nsarray *permissions = [[nsarray alloc] initwithobjects:                             @"user_likes",                             @"read_stream",                             @"publish_actions",                             nil];     fbsession *session = [[fbsession alloc] initwithpermissions:permissions];     [fbsession setactivesession:session]; } if([fbsession openactivesessionwithallowloginui:no]) {     uiimage *uploadimage=[uiimage imagenamed:@"2.png"];     nsdictionary *params = [nsdictionary dictionarywithobjectsandkeys:accesstoken, @"caacedeose0cbaafij51qowoobfocobm1e3v1zbzcnybszayspbqcxpuzcdzc620brwyvchxgd96zaosmnyrza9tyd9teq9q1m67wkx0n66yjtiyzbxczkizb7t3tulo5rysnbzbfgwezcenmxrf7xobe6dq6450nmb0hrjzi8prt18wzafu878ghnryp5vw4up3jgzcwpwmumxdzaozaxvosyzbnkq6i",                             postingstring, @"message",uploadimage,@"source",                             nil];     fbrequest *requesttopost = [[fbrequest alloc] initwithsession:nil                                                         graphpath:@"/me/feed"                                                        parameters:params                                                        httpmethod:@"post"];     fbrequestconnection *requesttopostconnection = [[fbrequestconnection alloc] init];     [requesttopostconnection addrequest:requesttopost completionhandler:^(fbrequestconnection *connection, id result, nserror *error)      {          nslog(@"facebook result >> %@", result);      }];     [requesttopostconnection start];  } else {     nslog(@"nothing bye"); } 

here plist file as

<key>cfbundleurltypes</key> <array>     <dict>         <key>cfbundletyperole</key>         <string>editor</string>         <key>cfbundleurlname</key>         <string></string>         <key>cfbundleurlschemes</key>         <array>             <string>fb74549074886xxxx</string>         </array>     </dict> </array> <key>cfbundleversion</key> <string>1.0</string> <key>facebookappid</key> <string>7454907xxxxxx</string> <key>facebookdisplayname</key> <string>cele­b­r­a­t­e­c­h­r­i­s­tmas</string> 

-(ibaction)camerabuttonpressed:(id)sender {   // here add image did finish method    if ([[fbsession activesession] isopen]) {     /*      * if current session has no publish permission need reauthorize      */     if ([[[fbsession activesession] permissions]indexofobject:@"publish_stream"] == nsnotfound) {          [[fbsession activesession] requestnewpublishpermissions:[nsarray arraywithobjects: @"publish_stream",nil] defaultaudience:fbsessiondefaultaudiencefriends                                               completionhandler:^(fbsession *session,nserror *error){                                                   [self postdata];                                               }];      }else{         [self postdata];     } }else{      /*      * open new session publish permission      */      [fbsession openactivesessionwithpublishpermissions:[nsarray arraywithobjects: @"publish_stream", nil]                                        defaultaudience:fbsessiondefaultaudiencefriends                                           allowloginui:no                                      completionhandler:^(fbsession *session, fbsessionstate status, nserror *error) {                                          if (!error && status == fbsessionstateopen) {                                              [self postdata];                                          }else{                                              nslog(@"error");                                          }                                      }]; }    }    -(void)postdata { uiimage *uploadimage=[uiimage imagenamed:@"2.png"]; nsdictionary *params = [nsdictionary dictionarywithobjectsandkeys:accesstoken, @"caacedeose0cbaafij51qowoobfocobm1e3v1zbzcnybszayspbqcxpuzcdzc620brwyvchxgd96zaosmnyrza9tyd9teq9q1m67wkx0n66yjtiyzbxczkizb7t3tulo5rysnbzbfgwezcenmxrf7xobe6dq6450nmb0hrjzi8prt18wzafu878ghnryp5vw4up3jgzcwpwmumxdzaozaxvosyzbnkq6i",                         postingstring, @"message",uploadimage,@"source",                         nil]; fbrequest *requesttopost = [[fbrequest alloc] initwithsession:nil                                                     graphpath:@"/me/feed"                                                    parameters:params                                                    httpmethod:@"post"]; fbrequestconnection *requesttopostconnection = [[fbrequestconnection alloc] init]; [requesttopostconnection addrequest:requesttopost completionhandler:^(fbrequestconnection *connection, id result, nserror *error)  {      nslog(@"facebook result >> %@", result);  }]; [requesttopostconnection start]; } 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -