简体   繁体   English

E / Volley:[145] BasicNetwork.performRequest:https://的意外响应代码404

[英]E/Volley: [145] BasicNetwork.performRequest: Unexpected response code 404 for https://

My first thread: Anything I try to store on database enters with value '0' 我的第一个线程: 我尝试存储在数据库中的所有内容都输入了值'0'

I solved that, but now I'm having another problem: Why am I having this error when I try to login? 我已解决了该问题,但现在又遇到了另一个问题:为什么尝试登录时出现此错误?

09-11 17:20:46.382 2577-5031/com.example.gustavo.loginregister D/NetworkSecurityConfig: No Network Security Config specified, using platform default
09-11 17:20:47.415 2577-5031/com.example.gustavo.loginregister E/Volley: [145] BasicNetwork.performRequest: Unexpected response code 404 for https://xxxxxxx.000webhostapp.com/Login.php
09-11 17:22:39.640 2577-6700/com.example.gustavo.loginregister E/Volley: [152] BasicNetwork.performRequest: Unexpected response code 404 for https://xxxxxxx.000webhostapp.com/Login.php

LoginActivity.java file: LoginActivity.java文件:

package com.example.gustavo.loginregister;

import android.app.AlertDialog;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.Volley;

import org.json.JSONException;
import org.json.JSONObject;

public class LoginActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        final EditText edtEmail = (EditText) findViewById(R.id.edtEmail);
        final EditText edtSenha = (EditText) findViewById(R.id.edtSenha);
        final Button btnLogin = (Button) findViewById(R.id.btnLogin);
        final TextView txtCadastreSe = (TextView) findViewById(R.id.txtCadastreSe);

        txtCadastreSe.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent registroIntent = new Intent(LoginActivity.this, RegisterActivity.class);
                LoginActivity.this.startActivity(registroIntent);
            }
        });

        btnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final String email = edtEmail.getText().toString();
                final String password = edtSenha.getText().toString();

                Response.Listener<String> responseListener = new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {
                            JSONObject jsonResponse = new JSONObject(response);
                            boolean success = jsonResponse.getBoolean("success");

                            if (success) {
                                String name = jsonResponse.getString("name");
                                String lastname = jsonResponse.getString("lastname");

                                Intent intent = new Intent(LoginActivity.this, UserAreaActivity.class);
                                intent.putExtra("name", name);
                                intent.putExtra("lastname", lastname);
                                intent.putExtra("email", email);
                                LoginActivity.this.startActivity(intent);

                            } else {
                                AlertDialog.Builder builder = new AlertDialog.Builder(LoginActivity.this);
                                builder.setMessage("Login Failed")
                                        .setNegativeButton("Retry",null)
                                        .create()
                                        .show();
                            }

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                };

                LoginRequest loginRequest = new LoginRequest(email, password, responseListener);
                RequestQueue queue = Volley.newRequestQueue(LoginActivity.this);
                queue.add(loginRequest);
            }
        });
    }
}

LoginRequest.java file: LoginRequest.java文件:

 package com.example.gustavo.loginregister; import com.android.volley.Response; import com.android.volley.toolbox.StringRequest; import java.util.HashMap; import java.util.Map; public class LoginRequest extends StringRequest { private static final String LOGIN_REQUEST_URL="https://wavecheck.000webhostapp.com/Login.php"; private Map<String, String> params; public LoginRequest(String email, String password, Response.Listener<String> listener){ super(Method.POST, LOGIN_REQUEST_URL, listener, null); params = new HashMap<>(); params.put("email", email); params.put("password", password); } @Override public Map<String, String> getParams() { return params; } } 

Login.php file: Login.php文件:

 <?php require("Password.php"); $con = mysqli_connect("localhost", "xxx", "xxx", "xxxx"); $email = $_POST["email"]; $password = $_POST["password"]; $statement = mysqli_prepare($con, "SELECT * FROM user WHERE email = ?"); mysqli_stmt_bind_param($statement, "s", $email); mysqli_stmt_execute($statement); mysqli_stmt_store_result($statement); mysqli_stmt_bind_result($statement, $colUserID, $colName, $colLastname, $colEmail, $colPassword); $response = array(); $response["success"] = false; while(mysqli_stmt_fetch($statement)){ if (password_verify($password, $colPassword)) { $response["success"] = true; $response["name"] = $colName; $response["lastname"] = $colLastname; $response["email"] = $colEmail; } } echo json_encode($response); ?> 

When you visit https://wavecheck.000webhostapp.com/Login.php directly it doesn't return JSON. 当您直接访问https://wavecheck.000webhostapp.com/Login.php时 ,它不会返回JSON。 It returns a 404 error page "There's nothing here, yet. This domain is ready to be registered.". 它返回一个404错误页面“此处还没有任何内容。该域已准备好注册。”。 This is a message from the host. 这是来自主机的消息。 Apparently you're using a FREE host, and the "wavecheck" subdomain isn't there. 显然您使用的是免费主机,并且“ wavecheck”子域不存在。 So you'd need to re-host your PHP script, or get in contact with the free host to figure out what happened. 因此,您需要重新托管您的PHP脚本,或与免费托管人联系以了解发生了什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WebSocket 握手:意外响应代码:404 - WebSocket handshake: Unexpected response code: 404 Tomcat 7 Websocket握手:意外的响应代码:404 - Tomcat 7 Websocket handshake: Unexpected response code: 404 WebSocket握手:意外的响应代码:404 - - WebSocket handshake: Unexpected response code: 404 - Websocket - WebSocket 握手期间出错:意外的响应代码:404 - Websocket - Error during WebSocket handshake: Unexpected response code: 404 javascript-WebSocket握手期间错误:意外的响应代码:404 - javascript - Error during WebSocket handshake: Unexpected response code: 404 意外的响应代码:200 - Unexpected response code: 200 与&#39;wss:// localhost:44300 / Home / websocketcon&#39;的WebSocket连接失败:WebSocket握手期间出错:意外响应代码:404 - WebSocket connection to 'wss://localhost:44300/Home/websocketcon' failed: Error during WebSocket handshake: Unexpected response code: 404 意外的响应代码426 - Unexpected response code 426 意外的响应代码:尝试连接Django通道时,JavaScript控制台出现404错误 - Unexpected response code: 404 error in javascript console while trying to connect Django channels 尝试连接到服务器时..失败:WebSocket 握手期间出错:意外响应代码:404 - when trying connecting to server.. failed: Error during WebSocket handshake: Unexpected response code: 404
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM