BasicNetwork.performRequest:http://localhost/database/login.php的意外响应代码403 [英] BasicNetwork.performRequest: Unexpected response code 403 for http://localhost/database/login.php

查看:75
本文介绍了BasicNetwork.performRequest:http://localhost/database/login.php的意外响应代码403的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Volley连接到MySql数据库.我创建了数据库表并编写了php函数,下面是Java代码.所有这些一直都在起作用,但直到昨天它才醒来,在logcat中给出了此错误,并且它没有返回任何响应,使用google chrome postman测试php脚本的效果很好,所以我以为我的Java代码有问题.

BasicNetwork.performRequest: http://192.168.43.71/database/login.php 的意外响应代码403/p>

我知道之前已经问过几个类似的问题,我已经经历了所有这些问题,而且似乎根本没有任何效果.我疯了.

private void login() {
      StringRequest jsonObjRequest = new StringRequest(Method.POST, Constants.ACCOUNTLOGIN,
              loginSuccessListener(),
              loginErrorListener()) {
      protected Map<String, String> getParams() throws com.android.volley.AuthFailureError {
          Map<String, String> params = new HashMap<String, String>();
          params.put("user_phone_number", sPhoneNumber);
          params.put("user_password", sPassword);
          return params;
          };
      }; 
  mVolleyQueue.add(jsonObjRequest);
     }

解决方案

首先检查是否可以在移动浏览器中打开相同的URL.我假设您使用Apache2.4.9网络服务器.如果您尚未更改默认值,则将获得拒绝权限". 要解决此问题,您需要在具有Apache设置的"httpd.conf"文件中更改一些值.

1-在DocumentRoot下更改目录xml标记,如下所示:

<Directory />
     AllowOverride none
     Require all granted
</Directory>

2-在"onlineoffline标记"下,更新该行,如下所示:

<Directory />
    ...
    ...
    ...
#   onlineoffline tag - don't remove
    Require all granted
</Directory>

注意:如果您使用的是Apache的旧版本,则需要google在httpd.conf中提供正确的语法

让我知道此更改是否有效. :)

I am using Volley to connect to MySql database. I created the database tables and wrote the php function and below is the java code. All this was working all along but just yesterday it woke up giving this error in the logcat and its not returning any response, testing the php script using google chrome postman works just fine so im thinking there is something wrong in my java code.

BasicNetwork.performRequest: Unexpected response code 403 for http://192.168.43.71/database/login.php

I know several questions like this have been asked before, i have gone through them all and nothing seems to work at all. I am going nuts.

private void login() {
      StringRequest jsonObjRequest = new StringRequest(Method.POST, Constants.ACCOUNTLOGIN,
              loginSuccessListener(),
              loginErrorListener()) {
      protected Map<String, String> getParams() throws com.android.volley.AuthFailureError {
          Map<String, String> params = new HashMap<String, String>();
          params.put("user_phone_number", sPhoneNumber);
          params.put("user_password", sPassword);
          return params;
          };
      }; 
  mVolleyQueue.add(jsonObjRequest);
     }

解决方案

First check if you can open the same url on your mobile browser. I assume you use Apache2.4.9 webserver. If you've not changed default values for you get "denied permission". To solve this problem you need change some values in "httpd.conf" file which has Apache settings.

1- Under DocumentRoot change Directory xml tag as following:

<Directory />
     AllowOverride none
     Require all granted
</Directory>

2- Under "onlineoffline tag" update the line as following:

<Directory />
    ...
    ...
    ...
#   onlineoffline tag - don't remove
    Require all granted
</Directory>

Note: If you use older version of Apache you need google for right syntax in httpd.conf

Let me know if this changes work or not. :)

这篇关于BasicNetwork.performRequest:http://localhost/database/login.php的意外响应代码403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆