public static Boolean Register(String account, String passWord,
String niceName) {
Boolean actionResult= false ;
String httpUrl= "http://221.181.127.43/gointel/UserHandler.ashx?Action=register&Account=" +account+ "&PassWord=" +passWord+ "&NiceName=" +niceName;
//httpGet 连接对象
HttpGet httpRequest = new HttpGet(httpUrl);
try
{
//取得HttpClinet对象
HttpClient httpclient= new DefaultHttpClient();
// 请求HttpClient,取得HttpResponse
HttpResponse httpResponse=httpclient.execute(httpRequest);
//请求成功
if (httpResponse.getStatusLine().getStatusCode()==HttpStatus.SC_OK)
{
//取得返回的字符串
String strResult=EntityUtils.toString(httpResponse.getEntity());
JSONObject jsonObject = new JSONObject(strResult) ;
//获取返回值,并判断是否正确
actionResult=jsonObject.getBoolean( "ActionResult" );
}
}
catch (Exception e)
{
return false ;
}
return actionResult;
}
|