相关疑难解决方法(0)

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

我正在使用Volley连接到MySql数据库.我创建了数据库表并编写了php函数,下面是java代码.所有这一切都在一直工作,但就在昨天它醒来在logcat中发出这个错误并且它没有返回任何响应,使用谷歌chrome postman测试php脚本工作得很好所以我认为我的java代码有问题.

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

我知道之前曾经问过这样的几个问题,我已经完成了所有这些问题,似乎没有什么工作可做.我疯了.

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);
     }
Run Code Online (Sandbox Code Playgroud)

php android android-volley

7
推荐指数
2
解决办法
1万
查看次数

Volley JsonObjectRequest在GET请求中发送标头

我试图从GET请求发送一些身份验证标头,我尝试使用Volley JsonObjectRequest调用:

Map<String,String> params=new HashMap<String,String>();
        params.put("token","fghjbvjhnjjk");
        activity.showDialog();
        JsonObjectRequest req = new JsonObjectRequest(Request.Method.GET,url,
                new JSONObject(params), new Response.Listener<JSONObject>() {

            @Override
            public void onResponse(JSONObject response) {
                Log.d(tag, response.toString());
                activity.hideDialog();
                try {
                    activity.onRequestServed(response, code);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                VolleyLog.d(tag, "Error: " + error.getMessage());
                Log.e(tag, "Site Info Error: " + error.getMessage());
                Toast.makeText(activity.getApplicationContext(),
                        error.getMessage(), Toast.LENGTH_SHORT).show();
                activity.hideDialog();
                try {
                    activity.onRequestServed(null,code);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        }); …
Run Code Online (Sandbox Code Playgroud)

android android-volley

4
推荐指数
1
解决办法
2万
查看次数

从 api 获取数据时出现意外响应代码 403

我想从某些 api 获取数据,我不知道我的 logcat 中哪里出了问题,它显示错误,意外的响应代码 403 这是我的主要活动

public class MainActivity extends AppCompatActivity {
    RequestQueue queue;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    queue=MySingleton.getInstance(this).getmRequestQueue();
    getList();
}
ArrayList getList(){
    JsonObjectRequest jsonObjectRequest =new JsonObjectRequest(Request.Method.GET,
            "https://newsapi.org/v2/top-headlines?country=in&apiKey=e613af58839749aab8f66bba967ab5a8", null
            , new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
                try {

                    String val=response.getString("status");
                    Log.d("json","status : "+val);
                    //i want to see this val in my logcat but its giving an error

                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
    }, new Response.ErrorListener() {
        @Override
        public void …
Run Code Online (Sandbox Code Playgroud)

java android

1
推荐指数
2
解决办法
4931
查看次数

标签 统计

android ×3

android-volley ×2

java ×1

php ×1