HTTP以编程方式请求Android

时间:2013-01-27 16:31:49

标签: android http request

我想用这种格式发送http post请求

{
  "Request":{
     "Data":{
      "RMID":"0910403545",
      "QID":"151",
      "RC":"5010",
      "Alg":"IMEI",
      "AlgID":"987654321",
      "IPD":"1223331",
      "Now":"27-01-2013"
  },
     "Signature":"5a185c480d11ebd39675977e40af34fe4a0121aa"
  }
}

我在我的Android应用程序中试过,这里是代码..

AsyncHttpClient client = new AsyncHttpClient();
RequestParams params = new RequestParams();
JSONObject object = new JSONObject();
object.put("RMID", "0910403545");
object.put("QID", "151");
object.put("RC", "5010");
object.put("Alg", "IMEI");
object.put("AlgID", "987654321");
object.put("IPD", "1223331");
object.put("Now", "27-01-2013");
params.put("Data", object.toString());
params.put("Signature", "5a185c480d11ebd39675977e40af34fe4a0121aa");
client.post(link, params, new AsyncHttpResponseHandler(){
    @Override
    public void onSuccess(String response) {
    // TODO Auto-generated method stub
        Log.d("XXX", response);
    }

    @Override
    public void onFailure(Throwable error, String response) {
        // TODO Auto-generated method stub
        Log.d("XXX", response);
    }
});
答案不是我所期待的。如果我在javascript中试过,那就不一样了。

0 个答案:

没有答案