Raj*_*tth 2 android android-networking android-volley
这是我的android代码
JSONObject params = new JSONObject();
params.put("username","rajesh@gmail.com");
params.put("password","hellothere");
JsonObjectRequest loginRequest = new JsonObjectRequest(
Request.Method.POST,
"http://192.168.2.67/tmp/test.php",
params,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject jsonObject) {
Log.d("","");
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Log.d("","");
}
});
requestQueue.add(loginRequest);
Run Code Online (Sandbox Code Playgroud)
php中的服务器代码
<?php
$usr = $_REQUEST['username'];
$pwd = $_REQUEST['password'];
$resp[$usr]=$pwd;
echo json_encode($resp);
?>
Run Code Online (Sandbox Code Playgroud)
我得到的回答是{"":null}
我尝试使用apache http cleint并且它有效地工作有什么办法可以用凌空来做到这一点吗?
To send parameters in request body you need to override either getParams() or getBody() method of the request classes
Source: Asynchronous HTTP Requests in Android Using Volley
| 归档时间: |
|
| 查看次数: |
18549 次 |
| 最近记录: |