获取MySql查询的响应

时间:2012-07-17 17:49:43

标签: php android json

我在android中有关于聊天程序的算法,但我在服务器端部分有问题。

我可以通过json将我的数据(如用户名,密码和电子邮件)存储到我的应用程序的数据库中,但我不知道如何将它们检入我的应用程序! (例如,将用户名检查查询的响应发送到我的应用程序中。)

提前致谢。

1 个答案:

答案 0 :(得分:1)

基本上,当您运行httpClient.execute时,它会返回响应,您需要使用该响应。

客户方:

HttpResponse resp = httpClient.execute( post );
DataInputStream is = new DataInputStream( resp.getEntity().getContent() );

服务器端取决于您使用的编程语言。例如,使用python:

    self.response.headers['Content-Type'] = 'text/vnd.aexp.json.resp'
    self.response.set_status( 200,"OK" )
    self.response.out.write( json.dumps( responseList ) )  

有关完整源代码和详细信息,请参阅此示例:

http://mylifewithandroid.blogspot.fi/2010/10/client-server-communication-with-json.html

修改
检查这是否为php服务器端:

http://www.happycode.info/php-json-response/