android - FQL Query in another FQL Query issue -


i started rebulding application integrate new facebook sdk 3.0.1 comply breaking changes scheduled july, 13.

all working perfect till then. attempting pull in newsfeed querying stream fql table did using earlier sdk.

the background:

my earlier query (code) was:

string qryfeeds =          "select post_id, created_time, updated_time, filter_key, actor_id, message, app_data, attachment, comments, likes, place, permalink, description, type stream filter_key in (select filter_key stream_filter uid = me() , type = 'newsfeed') limit 10 offset 0"; bundle bun = new bundle(); bun.putstring("method", "fql.query"); bun.putstring("query", qryfeeds); string result = utility.mfacebook.request(bun); jsonarray jafeeds = new jsonarray(result);  (int = 0; < jafeeds.length(); i++) {     jsonobject jofeeds = jafeeds.getjsonobject(i);      /** actor details **/     if (jofeeds.has("actor_id"))    {         actor_id = jofeeds.getstring("actor_id");         feeds.setactorid(actor_id);          // actor details global method         string[] strarractordetails =  userdetails.getactordetails(actor_id);         actor_name = strarractordetails[0];         actor_profile = strarractordetails[1];          // set details pojo arraylist         if (actor_name != null) {             feeds.setactorname(actor_name);         } else {             feeds.setactorname(null);         }          if (actor_profile != null)  {             feeds.setactorprofile(actor_profile);         } else {             feeds.setactorprofile(null);         }     } else {         actor_id = null;         feeds.setactorid(actor_id);          actor_name = null;         feeds.setactorname(actor_name);          actor_profile = null;         feeds.setactorprofile(actor_profile);     } } 

and in method getactordetails in userdetails class, make multiple calls either user, page or app fql tables fetch correct user details:

try {     // query user fql table     string queryuser =              "select name, pic_big " +             "from user " +             "where uid=" + stractorid;     bundle bunqryuser = new bundle();     bunqryuser.putstring("method", "fql.query");     bunqryuser.putstring("query", queryuser);     string resultqueryuser = utility.mfacebook.request(bunqryuser);     jsonarray jauser = new jsonarray(resultqueryuser);      if (jauser.length() == 0)   {          // query page fql table         string querypage =                  "select name, pic_big " +                 "from page " +                 "where page_id=" + stractorid;         bundle bunqrypage = new bundle();         bunqrypage.putstring("method", "fql.query");         bunqrypage.putstring("query", querypage);         string resultqrypage = utility.mfacebook.request(bunqrypage);         jsonarray japage = new jsonarray(resultqrypage);          if(japage.length() == 0)    {             // query application fql table             string queryapp =                      "select display_name, logo_url " +                     "from application " +                     "where app_id = " + stractorid;             bundle bunqryapp = new bundle();             bunqryapp.putstring("method", "fql.query");             bunqryapp.putstring("query", queryapp);             string resultqryapp = utility.mfacebook.request(bunqryapp);             jsonarray jaapp = new jsonarray(resultqryapp);              if (jaapp.length() == 0)    {                 // nothing @ moment             } else {                 (int j = 0; j < jaapp.length(); j++) {                     jsonobject joapp = jaapp.getjsonobject(j);                      // process result data                      return new string[] {stractorname, stractorprofile};                 }             }          } else {             (int j = 0; j < japage.length(); j++) {                 jsonobject jopage = japage.getjsonobject(j);                  // process result data                  return new string[] {stractorname, stractorprofile};             }         }     } else {         (int j = 0; j < jauser.length(); j++) {             jsonobject jouser = jauser.getjsonobject(j);              // process result data              return new string[] {stractorname, stractorprofile};         }     } } catch (exception e) {     e.printstacktrace(); } 

now question , current situation:

attempting replicate new sdk produces quite baffling result. code making use of newer api calls:

session.openactivesession(getactivity(), true, new session.statuscallback() {      @override     public void call(final session session, sessionstate state, exception exception) {          string qryfeeds =                  "select post_id, created_time, updated_time, filter_key, " +                 "actor_id, message, app_data, attachment, comments, " +                 "likes, place, permalink, description, type " +                 "from stream filter_key in " +                 "(select filter_key stream_filter " +                 "where uid = me() , type = 'newsfeed') " +                 "limit 10 offset 0";         bundle bun = new bundle();         bun.putstring("q", qryfeeds);          request request = new request(session, "/fql", bun, httpmethod.get, new request.callback() {              @override             public void oncompleted(response response) {                  // cast result in graphobject                 graphobject grphobject = response.getgraphobject();                  // check graphobject instance has data                 if (grphobject != null) {                      jsonobject joroot = grphobject.getinnerjsonobject();                      try {                          // cast joroot contents jsonarray                         jsonarray jafeeds = joroot.getjsonarray("data");                          (int = 0; < jafeeds.length(); i++) {                             jsonobject jofeeds = jafeeds.getjsonobject(i); //                                  log.e("jofeeds", jofeeds.tostring());                              // instantiate newsfeeddata class instance                             feeds = new newsfeeddata();                              if (jofeeds.has("actor_id"))    {                                  final string stractorid = jofeeds.getstring("actor_id");                                 log.e("stractorid", stractorid);                                 feeds.setactorid(stractorid);                                  string qryauthor =                                          "select name, pic_big " +                                         "from user " +                                         "where uid=" + stractorid;                                 bundle bunauthor = new bundle();                                 bunauthor.putstring("q", qryauthor);                                  request reqauthor = new request(session, "/fql", bunauthor, httpmethod.get, new request.callback() {                                      @override                                     public void oncompleted(response resauthor) {                                          graphobject grp = resauthor.getgraphobject();                                         jsonobject joroot = grp.getinnerjsonobject();                                          try {                                             jsonarray jauser = joroot.getjsonarray("data");                                              /* actor details user fql table */                                             if (jauser.length() != 0)   {                                                  (int = 0; < jauser.length(); i++) {                                                     jsonobject jouser = jauser.getjsonobject(i); //                                                          log.e("jouser", jouser.tostring());                                                      /* process result data */                                                  }                                              } else {                                                 string qrypage =                                                          "select name, pic_big " +                                                         "from page " +                                                         "where page_id=" + stractorid;                                                 bundle bunpage = new bundle();                                                 bunpage.putstring("q", qrypage);                                                  request reqpage = new request(session, "/fql", bunpage, httpmethod.get, new request.callback() {                                                      @override                                                     public void oncompleted(response respage) {                                                          graphobject grppage = respage.getgraphobject();                                                         jsonobject joroot = grppage.getinnerjsonobject();                                                          try {                                                             jsonarray japage = joroot.getjsonarray("data");                                                              /* actor details page fql table */                                                             if (japage.length() != 0)   {                                                                  (int = 0; < japage.length(); i++) {                                                                     jsonobject jopage = japage.getjsonobject(i);                                                                      /* process result data */                                                                 }                                                              } else {                                                              }                                                          } catch (exception e) {                                                             e.printstacktrace();                                                         }                                                      }                                                 }); request.executebatchasync(reqpage);                                              }                                          } catch (exception e) {                                             e.printstacktrace();                                         }  //                                              log.e("author response", resauthor.tostring());                                      }                                 }); request.executebatchasync(reqauthor);                             }                              /* add collected data arraylist */                             arrfeeds.add(feeds);                              lv.setadapter(adapter);                         }                      } catch (exception e) {                         e.printstacktrace();                     }                  } else {                  }              }         }); request.executebatchasync(request);      } }); 

the first query works fine , gets posts stream fql table. making nested queries user, page or app fql tables come last , therefore don't show in listview. nested queries not allowed? if not case, how nest multiple queries within primary stream query? necessary considering post's author can app or page , not normal user.

p.s.: sorry length of post. thought of not leaving out. :-)


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -