这是我使用 loopj 用于异步 Http 请求的代码。
AsyncHttpClient loopjClient = new AsyncHttpClient();
PersistentCookieStore loopjCookieStore = new PersistentCookieStore(this);
loopjClient.setCookieStore(loopjCookieStore);
RequestParams loopjParams = new RequestParams();
loopjParams.put("username", username);
loopjParams.put("email", emailID);
loopjParams.put("password", password);
Log.d(TAG, "RRRRRRlll");
loopjClient.post("http://www.example.com/", loopjParams, new AsyncHttpResponseHandler() {
@Override
public void onSuccess(int k,String response) {
super.onSuccess(k, response);
Log.d(TAG, "RRRRRR "+ response );
}
});
我的服务器响应字符串就是以下没有 HTML 标记的字符串
{"AUTHENTICATION":{"SUCCESS":false,"USERNAME":"unregistered","USERID":0},"ALERTBOX":{"SHOW":true,"MESSAGE":"Message : Username or email ID already registered. Please choose a different one."}}
但loopj
不会在onSuccess()
.
你能告诉我如何获取字符串还是我必须回退到默认的 Android http 库?
提前致谢。
编辑
如果我用“facebook”替换它而不是“example”(我的网站),我只会得到以下字符串作为响应,并带有 200 响应代码<?xml version="1.0" encoding="utf-8"?>