Getty Images API:帐户无效

时间:2016-01-30 08:43:07

标签: android image-processing

我正在使用GettyImages API:http://developers.gettyimages.com/api/docs/v3/search/images/get/

我将帐户处于非活动状态作为响应。在控制板中,我的状态为活动状态 无法弄清楚出了什么问题

以下是代码:

  String mySearch = "football";
    HashMap<String, String> header = new HashMap<String, String>();
    header.put("API_KEY", API_KEY);

    String url = "https://api.gettyimages.com/v3/search/images?phrase=football";
    if (isNetworkAvailable()) {
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url(url)
                .header("API_KEY", API_KEY)
                .build();
        Call call = client.newCall(request);
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                alertUserAboutError();
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {

                try {
                    String jsonData = response.body().string();
                    Log.v("Response: ", jsonData);

                }
                catch (IOException e)
                {
                    e.printStackTrace();
                    Log.d("Exception Caught: ",e.toString());
                }
            }
        });

1 个答案:

答案 0 :(得分:0)

如果您的API密钥正确, 然后你缺少请求授权标题。 请参阅Getty github项目以供参考: https://github.com/gettyimages/gettyimages-api_java