我想调用GitHub API返回基于以下任意搜索参数的存储库列表:param
所以custom_search_param是在运行时声明的。
我做了这个界面:
public interface GitHubClient {
String BASE_URL = "https://api.github.com/";
@GET("search/repositories")
Call<GitHubRepo> getReposForSearchParam (@Query("q") String custom_search_param);
}我在MainActivity onCreate中这样称呼它:
Retrofit retrofit = new Retrofit.Builder().baseUrl(GitHubClient.BASE_URL).addConverterFactory(GsonConverterFactory.create()).build();
GitHubClient gitHubClient = retrofit.create(GitHubClient.class);
Call<GitHubRepo> call = gitHubClient.getReposForSearchParam("tetris");
call.enqueue(new Callback<GitHubRepo>() {
@Override
public void onResponse(Call<GitHubRepo> call, Response<GitHubRepo> response) {
Log.d("resp",response.toString());
Log.d("respBody",response.body().toString());
}
@Override
public void onFailure(Call<GitHubRepo> call, Throwable t) {
Log.e("wentWrong", t.getMessage());
}
});我总是收到onFailure的回应:
E/wentWrong: javax.net.ssl.SSLProtocolException: SSL握手中止: ssl=0xb8679dd0: SSL库失败,通常协议错误:1407742E:ssl routines:SSL23_GET_SERVER_HELLO:tlsv1警报协议版本(外部/openssl/ssl/s23_clnt.c:741 0x9db10901:0x000 ) 00000)
是否有人知道这里出了什么问题,以及是否应该以不同的方式声明GitHubClient接口指定?
发布于 2018-06-11 13:08:18
由于GitHub api已禁用TLSv1.1,您至少需要一个支持TLSv1.1的设备或客户机。因此,当android设备低于Android4.4时,它将无法工作。见这里。
https://stackoverflow.com/questions/50797404
复制相似问题