发送Https请求但没有得到响应

时间:2017-07-25 09:33:32

标签: java android mysql http https

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

这是我的代码

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")) {

0 个答案:

没有答案