在java android app和PHP脚本之间交换数据最安全的方法? [重复]

Possible Duplicate:
How to implement communication between Java client application (Android) and PHP server application?

I'm busy with a project. My android app needs to request server info from time to time.

The solution i came up with was to write a php script. But how do you let the android java app communicate with the PHP script ?

I was thinking about something with a post/get request and the php script returning a html file with strings ?

Would love some advice, thanks in advance :)

From Android, do HTTP GET/POST requests to reach the PHP script. Have the PHP script return JSON formatted data - much easier to parse and deal with than HTML.

see this tutorial it will help you

connection between php android using http and json

you can exchange array between them by JSON,most of language support JSON. in php you can use json_encode(); json_decode(); to make json array.and Java should have something same as it. eg:


$array = array(
            "fname" => "Moein"
            "lname" => "Hoseini"
); $js = json_encode($array);