Question

I'm getting some user data with API /me/home. I want to ask that in which form shall I store the result- in JSONArray or JSONObject?

Please tell me the method to store data. I am using following procedure to get user data i am storing it in string now.

if (fb.isSessionValid()) {
   button.setImageResource(R.drawable.logout_button);
   pic.setVisibility(ImageView.VISIBLE);
   JSONObject obj=null;
   JSONArray feed = null;
   URL img_url = null;
   try {
      String JSONUser = fb.request("me");
      obj = Util.parseJson(JSONUser);
      String id = obj.optString("id");
      String name = obj.optString("name");
      String newsfeed=fb.request("me/home");

Please help me.

Was it helpful?

Solution

The result of /me/home will be of form-

{
    "data":
       [
          .. .. ..
       ]
}

So, take the result in a JSONObject, then for the key data save the result to a JSONArray and then use the data.

You can always check the results of the Graph API in Graph API Explorer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top