I wrote one android login app that get username and password from user. I whant to send username & password to server that is cakephp application.This is my android code:
httpclient=new DefaultHttpClient();
httppost= new HttpPost("http://10.0.2.2/ar/users/login?name="+name+"&password="+pass);
//Execute HTTP Post Request
response=httpclient.execute(httppost);
final ResponseHandler<String> responseHandler = new BasicResponseHandler();
result = httpclient.execute(httppost, responseHandler);
System.out.println("Response : " + response);
JSONArray jArray;
jArray = new JSONArray(result);
JSONObject j =new JSONObject();
j = jArray.getJSONObject(0);
JSONObject json = j.getJSONObject("User");
text = json.getString("last_name");
I write only this line in layout:
<?php echo $content_for_layout ?>
view code:
<?php echo json_encode($user); ?>
controller:
function login() {
if(isset($this->params['url']['name']))
$data = $this -> User -> findByuser_name($this->params['url']['name']);
if ($data && $data['User']['password'] == ($this->params['url']['password'])) {
$this -> set('user', $data);
} else {
$this -> set('error', true);
}
}
this code work goodly by enter below url in browser but don't work in android app! "localhost/ar/users/login?name=m_sepehri&password=111" anybody can help me?