Facebook server returns null data on query. Querying the same on Graph API Explorer gives me correct JSON Data

旧城冷巷雨未停 提交于 2019-12-13 00:52:59

问题


I'm trying to fetch the photos from particular album on facebook. Trying below URL gives me perfect data when querying at Graph API Explorer. But it returns null in my application code.

Also when I tried on browser it returns me:

{
 "data": { 
    ]
 }

which basically null:

URL = "https://graph.facebook.com/3386086936429/photos?limit=10";

try {
HttpClient hc = new DefaultHttpClient();
HttpGet get = new HttpGet(URL);
HttpResponse rp = hc.execute(get);

String st=rp.toString();

Log.e("RESPONSE", st);
Log.e("ACCESS_TOKEN",at);

if (rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
       String queryAlbums = EntityUtils.toString(rp.getEntity());

       int s=rp.getStatusLine().getStatusCode();
       String a=String.valueOf(s);
       Log.e("RESPONSE-IF", a);

       JSONObject JOTemp = new JSONObject(queryAlbums);

       JSONArray JAPhotos = JOTemp.getJSONArray("data");

      Log.e("JSONArray", String.valueOf(JAPhotos));
      Log.e("JSONArray-Length",String.valueOf(JAPhotos.length()));

Log:

02-14 00:12:34.280: E/RESPONSE(1320)org.apache.http.message.BasicHttpResponse@40518ac8
02-14 00:12:34.301: E/RESPONSE-IF(1320): 200
02-14 00:12:34.310: E/JSONArray(1320): []
02-14 00:12:34.310: E/JSONArray-Length(1320): 0

Where am I going wrong while querying?


回答1:


When I try to visit your ID on Facebook or query it via the Graph API, I get a "Unsupported get request" error. That tells me that either you've got the wrong id, or this id has restrictions on who can view it.

If you are able to view this information, then you can only get this information if you have an access token from a user who meets that object's restrictions.



来源:https://stackoverflow.com/questions/14861003/facebook-server-returns-null-data-on-query-querying-the-same-on-graph-api-explo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!