以下FQL查询在我将其粘贴到浏览器上时也有效,并且在API资源管理器中工作(xxxx替换为数字和访问令牌)
https://graph.facebook.com/fql?q=SELECT page_id from place WHERE (distance(latitude, longitude,"xxxxx","xxxxx") < xxxx)&access_token=<MY ACCESS TOKEN>
当我从我的java应用程序运行相同的代码时,我得到一个HTTP 400错误。知道是什么导致了这个吗?
以下代码实现了连接。 getInputStream()抛出异常(错误400)
connection = (URLConnection) new URL(url).openConnection();
input = connection.getInputStream();
答案 0 :(得分:0)
你是否尝试过URLEncode&#34; q&#34;参数值? 类似的东西:
String query = SELECT page_id from place WHERE (distance(latitude, longitude,"xxxxx","xxxxx") < xxxx)&access_token=<MY ACCESS TOKEN>;
String urlString = "https://graph.facebook.com/fql?q=" + URLEncoder.encode(query, "UTF-8"));
connection = (URLConnection) new URL(urlString ).openConnection();
input = connection.getInputStream();