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

与PHP对话从Android应用程序获取命令,php,android,codeigniter,url,Php,Android,Codeigniter,Url,我有一个android应用程序,正在尝试将数据发送到服务器上的PHP。服务器使用 $this->get('uname'); $this->get('pass'); 如果这很重要,我们会使用codeigniter 我目前拥有的异步方法中的Java代码是 InputStream response = null; URLConnection connection = new URL(urls[0]).openConnection(); connection.setRequestPrope

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

$this->get('uname');
$this->get('pass');
如果这很重要,我们会使用codeigniter

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

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

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

您的代码应该是这样的 正如@Ichigo Kurosaki在

对于Codeigniter端,函数名为user\u 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;
}
参考问题,这将帮助您它是$this->input->get();除非控制器中有一个名为get的方法。