开发者

Safest way to exchange data between java android app and PHP script? [duplicate]

开发者 https://www.devze.com 2023-04-03 02:41 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: How to implement communication between Java client application (Android) and PHP server application?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

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

I'm b开发者_Go百科usy 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 :)


see this tutorial it will help you

connection between php android using http and json


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.


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);

0

精彩评论

暂无评论...
验证码 换一张
取 消