i don't know why i cant send params to server using volley , my problem is when i'm trying to use velley to send params i get this error to my logcat,
[149] BasicNetwork.performRequest: Unexpected response code 403 for http://localhost/test/post.php
can every one help me to solve this problem ?
my php server :
<?php
if (isset($_POST['action'])){
$action = $_POST['action'];
} else {
echo "Invalid Data";
exit;
}
if($action="read"){
echo "read";
}
?>
my request :
String tag_string_req = "string_req";
String url = "http://localhost/test/post.php";
StringRequest strReq = new StringRequest(Request.Method.POST,
url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d("TAG", response.toString());
Log.d("LOG", "success");
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d("TAG", "Error: " + error.getMessage());
}
}){
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put("action", "read");
return params;
}
};
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
I think the problem is your URL parameter. "localhost" is a word that connecting with the device itself, and your server can't run on it. instead of localhost, you need to write the IP of the computer that running the server.
example: "http://replace_it_with_the_ip/test/post.php";