Android 和 http 通信

发布于 2024-10-21 03:45:47 字数 496 浏览 2 评论 0原文

我已经在这里和 anddev 上查看了合适的回复,但没有找到合适的内容。 问题是:我的朋友有一个 iPhone 即时聊天应用程序,由于我有一些基本的 Android 经验,他让我检查一下将其“移植”到 Android 上。因此,在设置 UI 之前,我决定研究一下我没有太多经验的 php。我知道 UI 需要一个数组来调用联系人,但我不确定是否从 php.ini 中检索信息。

我怎么知道我是否可以使用他的脚本?我还没有找到任何关于 Android 和 Php 的好的教程 - 有人找到吗?

我现在不妨学习这些东西,因为我的下一个应用程序将需要在其中使用在线数据库 - 我知道他有用户和密码,并且他希望能够在 iPhone 和 Android 客户端之间发送即时消息。

感谢您提供的任何帮助!

编辑:

是的,这个问题与从android到远程服务器的http请求更相关;我已经相应地更改了标签和主题,但仍然希望获得 Android 友好的 php 编写指南。谢谢你!

I have looked on here and anddev for a suitable response, but haven't found anything suitable.
Here is the question: My friend has an instant chat application with iPhone, and since I have some basic android experience he asked me to check out "porting" it to Android. So before I set up the UI, I decided to look into php which I don't have much experience with. I know the UI will need an array to call contacts, but I'm not sure about retrieving the information from the php.

How do I know if I can use his script or not? I haven't found any good tutorials about Android and Php - has anyone found one?

I might as well learn this stuff now because my next app will require an online database to be used in it - I know his has users and passwords, and he'd like to be able to send im's between iPhone and Android clients.

Thanks for any help you may provide!

EDIT:

Yes, this issue is more related to http requests from android to a remote server; I have changed the tags and subject accordingly, but would still appreciate a guide to android-friendly php writing. Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巾帼英雄 2024-10-28 03:45:47

确实没有Android 友好的 PHP,但有移动友好的 PHP。基本上,您需要 PHP 脚本发出易于在应用程序中解析的内容(例如 XML 或 JSON),而不是标准 HTML。之后,您需要做的就是弄清楚 API 在服务器端应该是什么样子。即服务器需要提供哪些功能以及如何提供这些功能。您要使用简单的 HTTP 身份验证还是要使用更复杂的身份验证?

至于他的聊天应用程序,我想如果他已经有 iPhone 版本,那么你根本不需要打扰服务器端。您所需要做的就是弄清楚哪些 URL 和参数用于哪些操作。你还需要问他他的服务器使用什么数据格式。如果是 XML,则需要找到一个 XML 解析器,如果是 JSON,则需要找到一个 JSON 解析器等(通过 Google 有大量关于如何在 Android 中执行这两项操作的教程)。我首先会从较高的层面而不是 Objective-C 的细节上询问他,他的聊天应用程序如何与服务器进行通信。然后,您可以使用它来构建应用程序,以相同的方式进行通信。

There really isn't Android-Friendly PHP but there is mobile friendly PHP. Basically, you need your PHP scripts to emit something that is easy to parse in an application (like XML or JSON) rather than the standard HTML. After that, all you need to do is figure out what the API should look like on the server side. That is, what functions does the server need to provide and how is it going to provide them. Are you going to use simple HTTP authentication or are you going to use something more complicated?

With regards to his chat application, I would imagine that if he already has an iPhone version, then you won't need to mess with the sever side at all. All you need to do is figure out what URLs and parameters to use for what operations. You also need to ask him what data format his server uses. If it's XML, you need to find an XML parser, if it's JSON then you need to find a JSON parser etc. (there are plenty of tutorials on how to do both in Android via Google). I would start by asking him, at a high-level, not with Objective-C specifics, how his chat application communicates with the sever. You can then use that to build your application to communicate in the same manner.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文