1

我正在尝试从 facebook 上的特定相册中获取照片。在查询时,下面的尝试URL给了我完美的数据Graph API Explorer。但它在我的应用程序代码中返回 null。

此外,当我在浏览器上尝试时,它返回给我:

{
 "data": { 
    ]
 }

基本上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()));

日志:

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

查询时我哪里出错了?

4

1 回答 1

0

当我尝试在 Facebook 上访问您的 ID 或通过 Graph API 查询时,我收到“不支持的获取请求”错误。这告诉我要么你的 id 有误,要么这个 id 对谁可以查看有限制。

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.

于 2013-02-13T19:45:15.763 回答