Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/190.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 发送Https请求但未获得响应_Java_Android_Mysql_Http_Https - Fatal编程技术网

Java 发送Https请求但未获得响应

Java 发送Https请求但未获得响应,java,android,mysql,http,https,Java,Android,Mysql,Http,Https,我正在向mysql服务器发送Https请求,但在本地主机上执行相同的任务时没有得到响应。我没有使用Https的经验,请给我解决方案,并解释Http和Https请求发送到mysql服务器的区别,希望有人帮助我提前感谢 这是我的密码 protected String doInBackground(String... params) { String emailSend = params[0]; String tokenSend = pa

我正在向mysql服务器发送Https请求,但在本地主机上执行相同的任务时没有得到响应。我没有使用Https的经验,请给我解决方案,并解释Http和Https请求发送到mysql服务器的区别,希望有人帮助我提前感谢

这是我的密码

protected String doInBackground(String... params) {
                String emailSend = params[0];
                String tokenSend = params[1];
                String deviceIdSend = params[2];
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
                nameValuePairs.add(new BasicNameValuePair("email", emailSend));
                nameValuePairs.add(new BasicNameValuePair("token", tokenSend));
                nameValuePairs.add(new BasicNameValuePair("deviceId", deviceIdSend));
                try {
                    HttpClient httpClient = new DefaultHttpClient();
                    HttpPost httpPost = new HttpPost("https://xyz/xyz/xyz.php");
                    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                    HttpResponse response = httpClient.execute(httpPost);
                    HttpEntity entity = response.getEntity();

                    is = entity.getContent();
                    BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"), 8);
                    StringBuilder sb = new StringBuilder();
                    String line = null;
                    while ((line = reader.readLine()) != null) {
                        sb.append(line);
                    }
                    result = sb.toString();
                } catch (ClientProtocolException e) {

                } catch (IOException e) {

                }
                return "success";
            }
            @Override
            protected void onPostExecute(String resultN) {
                super.onPostExecute(resultN);
                String s = resultN.trim();
                //dialog.dismiss();
                if (s.equalsIgnoreCase("success")) {
                    if (result.contains("Pass")) {
受保护的字符串doInBackground(字符串…参数){
字符串emailSend=params[0];
字符串tokenSend=params[1];
字符串deviceIdSend=params[2];
List nameValuePairs=新的ArrayList();
添加(新的BasicNameValuePair(“email”,emailSend));
添加(新的BasicNameValuePair(“token”,tokenSend));
添加(新的BasicNameValuePair(“deviceId”,deviceIdSend));
试一试{
HttpClient HttpClient=新的DefaultHttpClient();
HttpPost HttpPost=新的HttpPost(“https://xyz/xyz/xyz.php");
setEntity(新的UrlEncodedFormEntity(nameValuePairs));
HttpResponse response=httpClient.execute(httpPost);
HttpEntity=response.getEntity();
is=entity.getContent();
BufferedReader reader=新的BufferedReader(新的InputStreamReader(is,“UTF-8”),8;
StringBuilder sb=新的StringBuilder();
字符串行=null;
而((line=reader.readLine())!=null){
某人附加(行);
}
结果=sb.toString();
}捕获(客户端协议例外e){
}捕获(IOE异常){
}
返回“成功”;
}
@凌驾
PostExecute上受保护的void(字符串结果){
super.onPostExecute(resultN);
字符串s=resultN.trim();
//dialog.dismise();
如果(s.equalsIgnoreCase(“成功”)){
if(result.contains(“Pass”)){

尝试创建一个
http
而不是
https
使用https有很多问题,并且没有得到解释。您需要为https连接编写证书。还可以使用此客户端:tru从postman客户端运行url我也面临这个问题@Nenco您能解释一下吗这篇文章解释了您需要知道的一切: