Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8810733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:11:24+00:00 2026-06-14T03:11:24+00:00

The obj.optString(picture) does not seem to get the picture url .jpeg as a string.

  • 0

The obj.optString(“picture”) does not seem to get the picture url .jpeg as a string.

public static List<Photo> getPictures(AuthProvider provider, String source, String type) {
List<Photo> photos = new LinkedList<Photo>();
if (provider.getProviderId() == Constants.FACEBOOK) {
    final String BASE_URL_FACEBOOK = "https://graph.facebook.com/";
    String url = BASE_URL_FACEBOOK + source + "/feed";

    try {
        Response response = provider.api(url, MethodType.GET.toString(), null, null, null);

        Log.d("AndroidAppPhotoUtil", "Status " + response.getStatus() + " returned by facebook get query " + url);
        if (response.getStatus() == 200) {
            String respStr = response.getResponseBodyAsString(Constants.ENCODING);
            JSONObject resp = new JSONObject(respStr);
            JSONArray data = resp.optJSONArray("data");
            if (data != null)
                for (int i = 0; i < data.length(); i++) {
                    JSONObject obj = data.getJSONObject(i);
                    Photo p = new Photo();

                    p.setId(obj.optString("id"));
                    p.setPicture(obj.optString("picture"));


                    if (isEmpty(type) || type.equals(obj.optString("type"))) {
                        photos.add(p);
                    }

                }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
return photos;  
}

.

"id": "466138393436802_466165356767439", 
      "from": {
    "name": "Dimitri Nicolopoulos", 
    "id": "100004358376630"
      }, 
      "to": {
    "data": [
      {
        "name": "My Test Event", 
        "start_time": "2012-11-13", 
        "location": "Saewrreritvh", 
        "id": "466138393436802"
      }
    ]
      }, 
      "picture": "http://photos-a.ak.fbcdn.net/hphotos-ak-ash3/533694_123231957832083_231056016_s.jpg", 
      "link": "http://www.facebook.com/photo.php?fbid=123231957832083&set=oa.160219667456793&type=1&relevant_count=1", 
      "icon": "http://static.ak.fbcdn.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif", 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:11:25+00:00Added an answer on June 14, 2026 at 3:11 am

    I added put your JSON code inside a ‘{‘ and a ‘}’ and I did this:

        String respStr = "{\"id\":\"466138393436802_466165356767439\",\"from\":{\"name\":\"Dimitri Nicolopoulos\",\"id\":\"100004358376630\"},\"to\":{\"data\":[{\"name\":\"My Test Event\",\"start_time\":\"2012-11-13\",\"location\":\"Saewrreritvh\",\"id\":\"466138393436802\"}]},\"picture\":\"http://photos-a.ak.fbcdn.net/hphotos-ak-ash3/533694_123231957832083_231056016_s.jpg\",\"link\":\"http://www.facebook.com/photo.php?fbid=123231957832083&set=oa.160219667456793&type=1&relevant_count=1\",\"icon\":\"http://static.ak.fbcdn.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif\"}";
        JSONObject resp = new JSONObject(respStr);
        System.out.println(resp.get("picture"));
    

    This works. Also, your data is always null. The “data” is actually under the “to” key. So you can do

        String respStr = "{\"id\":\"466138393436802_466165356767439\",\"from\":{\"name\":\"Dimitri Nicolopoulos\",\"id\":\"100004358376630\"},\"to\":{\"data\":[{\"name\":\"My Test Event\",\"start_time\":\"2012-11-13\",\"location\":\"Saewrreritvh\",\"id\":\"466138393436802\"}]},\"picture\":\"http://photos-a.ak.fbcdn.net/hphotos-ak-ash3/533694_123231957832083_231056016_s.jpg\",\"link\":\"http://www.facebook.com/photo.php?fbid=123231957832083&set=oa.160219667456793&type=1&relevant_count=1\",\"icon\":\"http://static.ak.fbcdn.net/rsrc.php/v2/yz/r/StEh3RhPvjk.gif\"}";
        JSONObject resp = new JSONObject(respStr);
        JSONObject data = (JSONObject) resp.getJSONObject("to").getJSONArray("data").get(0);
        System.out.println(data);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Once I do $(#obj).load(url) is there a way to get the loaded url from
In Obj-C, what does it mean in simple terms; CoreData is not thread safe
obj[i]['Weight'] = parseFloat(0); obj[i]['Height'] = parseFloat(0); obj[i]['Temperature'] = parseFloat(0,10); // This does not work...
because obj, the playingCard object is created inside a nested for loop does that
var obj = { method: 'feed', link: mylinkt, picture: 'http://fbrell.com/f8.jpg', name: 'Poonkt.us - My
object obj = Hello; string str1 = (string)obj; string str2 = obj.ToString(); What is
I'm new to obj-c/iOS/parse so this is a basic question. I've managed to get
object obj = new object[] { new object(), new object() }; How does this
String obj = null; obj= new String(Samuel); //vs String obj = null; obj=Samuel; Is
I have .obj files each with several texture files. Does three.js comes out of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.