与PHP对话从Android应用程序获取命令


Talking to PHP get commands from Android app

我有一个android应用程序,正在尝试将数据发送到服务器上的PHP。服务器通过获取php数据

$this->get('uname');
$this->get('pass');

如果这很重要的话,我们确实使用代码点火器

我目前拥有的异步方法内部的Java代码是

InputStream response = null;
URLConnection connection = new URL(urls[0]).openConnection();
connection.setRequestProperty("uname" , Username);
connection.setRequestProperty("pass", Password);
response = connection.getInputStream();

当我运行这个程序时,代码总是返回null,但无论如何都应该返回一个JSON数组。我已经检查了URL,它是正确的。我做错了什么?谢谢

您的代码应该是这样的对于你的android端,正如@Ichigo Kurosaki在android 中发送POST数据时提到的那样

对于Codeigniter端,余弦函数名为user_login

function user_login(){
$uname = $this->input->get_post('uname'); //get_post will work for both type of GET/POST request
$pass =  $this->input->get_post('pass');
$result=$this->authenticate->actLogin($uname,$pass  ); //considering your authenticating user and returning 1,0 array as success/failure
$this->output
    ->set_content_type('application/json')
    ->set_output(json_encode($result));
exit;
}