android - How to get friends info that requires permission like B'day using facebook graph api -


i'm having android button login.

below onclick listener of button.

btnloginfb.setonclicklistener(new view.onclicklistener() {  @ override public void onclick(view v) {       session s = new session(startup.this);     session.setactivesession(s);     session.openrequest request = new session.openrequest(startup.this);      list < string > permissions = new arraylist < string > ();     permissions.add("friends_birthday");     permissions.add("friends_location");     request.setpermissions(permissions);      request.setcallback(new session.statuscallback() {          @         override         public void call(session session, sessionstate state, exception exception) {              if (session.isopened()) {                  request.newmyfriendsrequest(session.getactivesession(), new request.graphuserlistcallback() {                      @                     override                     public void oncompleted(list < graphuser > users, response response) {                          if (users != null) {                               (int = 0; < users.size(); i++) {                                 string frndloc = "empty";                                  try {                                     users.get(i).getlocation().getproperty("name");                                     frndloc = "" + users.get(i).getlocation().getproperty("name");                                 } catch (exception e) {}                                  toast.maketext(startup.this, users.get(i).getbirthday() + " - " +                                     users.get(i).getname() + "\n" +                                     frndloc, toast.length_long).show();                             }                         }                      }                 }).executeasync();               } // end of if (session.isopened())         } // end of call     });     s.openforread(request); } }); 

the problem i'm getting null both b'day , location of friend.

request friendrequest = request.newmyfriendsrequest(activesession, new graphuserlistcallback() {                     @override                     public void oncompleted(final list<graphuser> users, response response) {                               arraylist<string> o = new arraylist<string>();                             (graphuser u : users) {                                 o.add(u.getinnerjsonobject().tostring());                             }                             getsherlockactivity().startservice(                                     new intent(getsherlockactivity(), insertindbservice.class).putextra("fbdata", o));                          }                      }                 }); 

parse reponse

int count = users.size();             (int = 0; < count; i++) {                 string name = "", id = "", photourl = "";                 string birthday = "", location = "";                 string website = "";                 jsonobject o = null;                 try {                     o = new jsonobject(users.get(i));                 } catch (jsonexception e) {                  }                 try {                     id = o.getstring("id");                     name = o.getstring("name");                     photourl = o.getjsonobject("picture").getjsonobject("data").getstring("url");                 } catch (jsonexception e) {                     e.printstacktrace();                     dbfacebookmain.deletefacebook();                 }                  try {                     location = o.getjsonobject("location").getstring("name");                 } catch (jsonexception e) {                  }                 try {                     birthday = o.getstring("birthday");                 } catch (jsonexception e) {                  }                 try {                     website = o.getstring("website");                 } catch (jsonexception e) {                  } 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -