[英]What must I do to receive JSON data from a server on an android app
I have PHP
script on the server side which executes the SQL
query and produces a JSON
string from it. 我在服务器端有PHP
脚本,该脚本执行SQL
查询并从中生成JSON
字符串。 But how do I get that code to execute to then retrieve and decode the JSON
on the Android
app? 但是,如何获取要执行的代码,然后在Android
应用上检索和解码JSON
?
I am quite new to android so as much help would be very appreciated. 我对android很陌生,因此非常感谢您的帮助。
I can't write you the whole tutorial but i can give you a to-do list which you can check your progress. 我无法为您写完整的教程,但是我可以给您一个待办事项清单,您可以检查进度。
Your application to generate JSON script in txt, or real time response. 您的应用程序以txt或实时响应的形式生成JSON脚本。
Setup your backend server(you have sql server already and also PHP, so i guess you have set it up already, probably WAMP or similar), which is the endpoint/url path to generate the response required, in this case your JSON response. 设置您的后端服务器(您已经有sql server,也有PHP,所以我想您已经设置了它,可能是WAMP或类似的东西),这是生成所需响应的端点/ URL路径,在这种情况下为JSON响应。
Check the API is working or not by using "advanced rest client" or simple type your endpoint in browser, if you can get the correct response from it, the API is working as expected. 通过使用“高级其余客户端”或在浏览器中简单键入端点来检查API是否正常工作,如果可以从中获得正确的响应,则表明API是否按预期工作。
Created your android app, with simple HTTP request/response, send a HTTP request to the url/path you setup, see if you can get the JSON response or not. 使用简单的HTTP请求/响应创建了您的android应用,将HTTP请求发送到您设置的url /路径,看看是否可以获得JSON响应。
Please comment here if you need further details, this is relatively easy and should be able to finished in 1 day for beginner. 如果您需要更多详细信息,请在这里发表评论,这相对容易,对于初学者来说应该可以在1天之内完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.