java - 使用 Eventful API[JSON] 未获得结果

标签 java json request

我正在尝试使用 Eventful API 获取附近的事件列表,但无法通过请求获得任何结果。 有谁知道这里有什么问题吗?

这是我的 JSON 请求:String url_request = "http://eventful.com/json/events?q=music&l=Singapore&api_key= "+ API_KEY;

这是我当前的输出:

{"spoken_search_data":null,"location":{"geo_ip_fail":"0","location_type":null,"location_id":null,"geo_ip_guess":null,"meta_name":"全局","Pretty_name":"全局"},"localized_base_url":"http://eventful.com ","is_default_eventful_site":"1","facebook_app_namespace":"eventful","home_url":"/"}

package EventTest.EventTest;

import java.io.IOException;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;


public class App 
   {
      private static final String API_KEY = "my_api_key";
      OkHttpClient client = new OkHttpClient();

      public static void main( String[] args ) throws IOException 
   {
    App request = new App();

    String url_request = "http://eventful.com/json/events?q=music&l=Singapore&api_key=" + API_KEY;
        String response = request.run(url_request);

    System.out.println(response);

}

public String run(String url) throws IOException {
    Request request = new Request.Builder().url(url).build();

    Response response = client.newCall(request).execute();
    return response.body().string();
  }
}

最佳答案

通过更改 JSON 请求来设法获得所需的结果:

字符串 url_request =

"http://api.eventful.com/json/events/search?keywords=music&location=Singapore&app_key=my_app_key ";

关于java - 使用 Eventful API[JSON] 未获得结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42115863/

相关文章:

Java JButton.setAction(...) null 的按钮文本

java - java发送邮件时出现问题

java - 我怎样才能使 JLabel 在一段时间后消失?

python 发布请求不适用于 Minio 服务器导入

java - 设置语言 springMVC/Thymeleaf

arrays - 如何使用jq数组值返回true

javascript - ReactJS - 如何从 json-server 迁移到 .json 文件?

c# - 如何忽略/跳过/处理 HttpWebResponse 错误并仍然将 JSON 返回到我的代码?

php - 带有订阅的 Stripe 付款请求按钮

asp.net - 如何将整个 POST 数据转储到 ASP.NET 中的文件