obj.optString("picture") 似乎没有将图片 url .jpeg 作为字符串。
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",