【发布时间】:2015-10-09 19:05:23
【问题描述】:
我想使用 HttpsUrlConnection 获取 Facebook 帖子的 cmets 这是网址https://graph.facebook.com/399455050251075/comments?access_token={my_access_token}
String urlAddress = "https://graph.facebook.com/" + postId + "/comments?access_token=" + "{my_access_token}";
try {
URL url = new URL(urlAddress);
HttpsURLConnection httpURLConnection = (HttpsURLConnection) url
.openConnection();
httpURLConnection.setDoInput(true);
httpURLConnection.setDoOutput(true);
httpURLConnection.setReadTimeout(10000);
httpURLConnection.setConnectTimeout(10000);
httpURLConnection.setRequestMethod("GET");
String response = ConnectionController.getResponse(httpURLConnection);
Log.v(Constants.TAG, urlAddress);
Log.v(Constants.TAG, response);
} catch (IOException e) {
e.printStackTrace();
}
它在浏览器上运行良好,但在 Android 中我得到 FileNotFoundException
注意:我不想使用 Facebook SDK 或任何其他库
【问题讨论】:
-
找不到哪个文件?这似乎是您的构建而不是 API 的问题
-
您确认
postId的值正确吗?而且您的访问令牌周围实际上并没有花括号,对吗?如果您将完整的 URL 作为静态值写入代码中,而不将变量放入其中,您会得到相同的结果吗? -
是的,我在浏览器相同的 url 中尝试过,它可以工作
标签: android facebook facebook-graph-api