search
Homephp教程php手册php Android 使用简介 JSON XML 区别

php Android 使用简介 JSON XML 区别

一个app通信接口三要素:
1.接口地址:(http://app.com/api.php?format=xml)
2.接口文件 :(api.php处理一些业务逻辑)
3.接口通信数据


App如何进行通信
1.App发送http请求给服务器
2.服务器处理后返回数据给App
与b/s访问方式不同:
b/s模式访问服务器页面的地址可以在地址栏看到而app访问看不到地址,已经被封装起来。
b/s模式返回数据通常是html,而要给app返回的数据格式和 JSON和XML


JSON和XML
XML:扩展标记语言(Extensible Markup Language ),可以用来标记数据,定义数据类型,是一


种允许用户对自己的标记语言进行定义的源语言。
特点:XML可以节点自定义,跨平台。

根节点
名字



JSON (JavaScript Object Notation) 一种轻量级的数据交换格式,具有良好的可读性和便于快


速编写的特性。可在不同平台之间进行数据交换。JSON采用兼容性很高,完全独立于语言文本格


式。这些特性是JSON成为理想的数据交换语言。


第一种,解析出字符串: “s”(用这个格式的少,不便于理解)
第二种,解析出数组 {"title":"david","from":"qingdao","decrip":"hello"}(key:value 便


于理解,所以这种常用)


xml和json区别:
1.可读性:xml结构层次清晰,json输出类似字符串,所以xml可读性好
2.php生成数据方面:php如何生成json数据:json_encode($arr);
如何生成xml数据:封装多个字符串,一起输出。
json只用一个函数,很方便;
3.传输速度:
json没有标签,数据小,所以传输快。


app接口功能:
1.获取数据:从数据库或缓存中获取数据,然后通过接口数据返回给客户端。如:主界面数据加


载。
2.提交数据:(get post),通过接口提交数据给服务器,然后服务器入库处理,或者其他操作。类


似于web方面的提交表单。如意见反馈。


版本升级接口 :提交当前版本数据,获取是否更行数据。
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor