首页 > 解决方案 > 使用密钥保护 OkHttp

问题描述

我有这个代码:

JSONParser jsonParser1 = new JSONParser();
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
        .url("url")
        .build();
Call call = client.newCall(request);

call.enqueue(new okhttp3.Callback() {
    @Override
    public void onFailure(Call call, IOException e) {
        //observe reason of failure using
        e.printStackTrace();
    }

    @Override
    public void onResponse(Call call, Response response) throws IOException {
        if(response.isSuccessful()){
    }
}

目前代码使用它从“url”调用json信息。

我想更改代码,以便它通过 url 传递一个键,如果该键与 PHP 中检查的键匹配,它会返回数据。

标签: javaphpandroidmysqlokhttp

解决方案


推荐阅读