如何用php写app接口[原创]

人生就如一列永不停止的列车,no one knows when or where to stop.总有那些美好,值得永远怀念。也总有那些希望,值得你无怨无悔的付出,追逐。去年年底带着女儿一起坐火车会湖北老家,她在火车上,三岁的样子,活泼,调皮,可爱的样子,永远停在那儿,不会有一样的了吧。cherish this memory forever.

现在app这么火,作为一个phper,应该知道如何写app的接口,下面做一个讲解。

Index:

第1章 APP接口简介
-
第2章 封装通信接口方法

2-1 JSON方式封装通信接口 (14:39)
2-2 PHP生成XML数据 (12:02)
2-3 XML方式封装通信接口 (17:50)
2-4 综合方式封装通信数据方法 (11:15)

-
第3章 核心技术

3-1 静态缓存 (17:16)
3-2 Memcache和Redis缓存技术 (24:07)
3-3 定时任务 (16:46)

-
第4章 APP接口实例

4-1 单例模式连接数据库 (18:29)
4-2 首页APP接口开发之方案一(上) (15:49)
4-3 首页APP接口开发之方案一(下) (11:03)
4-4 读取缓存方式开发首页接口 (19:21)
4-5 定时读取缓存方式开发首页接口 (16:32)
最近学习
4-6 版本升级分析及数据表设计 (08:15)
4-7 版本升级接口开发及演示(上) (19:26)
4-8 版本升级接口开发及演示(下) (09:29)
4-9 APP错误日志接口 (13:22)

第一章 APP接口简介

  什么是app接口?app接口就是用服务端程序如php写好的脚本,以供app客户端请求而获得数据的一个东西。比如一个视频app的首页,肯定有一些视频列表,那么当你打开这个app时,这个封装在app里的这个首页其实会去请求一个远程php文件如:http://www.example.com/index.php 去获得需要展示在首页的视频列表数据。前段工程师拿到这些数据,就会按照特定的设计,将这些内容展示出来了。

  接口要实现的目的就是这样。一个app内部通常需要访问多个php接口来获得不同的数据。下面具体讲一讲接口实现的流程以及实现接口需要的一些核心的技术。

第2章 封装通信接口方法

在正式的进入app接口学习之前,我们来回顾一下Php的接口知识,看下面代码:

interface.php

<?php
/**
*@description php接口回顾
*@author doubi
*@date 2015/07/19
*/ interface People{
public function say();
public function dance();
} interface Animal{
public function bite();
} class Man implements People{
public function say(){
echo 'i can say';
} public function dance(){
echo 'i can dance';
}
} class Woman implements People{
public function say(){
echo 'i can say girl voice';
} public function dance(){
echo 'i can dance like a goose';
}
} class Bird implements Animal{
public function bite(){
echo 'i can bite';
}
} class Hybreed implements People,Animal{
public function say(){
echo 'i can say';
} public function dance(){
echo 'i can dance';
} public function bite(){
echo 'i can bite';
}
} $hybreed = new Hybreed;
echo $hybreed->say()."\r\n";
echo $hybreed->dance()."\r\n";
echo $hybreed->bite()."\r\n";

接口存在的意义就是实现“多重继承”,准确的来说应该就做“多重实现“,因为一个php类只能有一个父类,而一个类却可以实现多个接口,就像上面代码interface.php中的Hybreed类,即实现了people接口,又实现了Animal接口,而通过这种多重继承,最终的$hybreed即获得了人类的say和dance的方法,又获得了动物的bite方法。而Man类和Woman类分别实现People的接口,采用不同的内容去重写了say和dance方法,正是一种多态的体现。

现在主流的通信接口返回的数据主要有JSON和XML两种格式。这两种格式各有优缺点。JSON的优势是生成方便,体积小,更便于传输,缺点是不便于阅读。而XML的优点是便于阅读,但是体积大,生成较JSON要麻烦的多。

2-1 JSON方式封装通信接口 (14:39)

先上代码:

response.class.php

<?php

/**
*description 用于返回指定数据格式的类
*@param $code [int] 返回的状态码
*@param $message [string] 返回的状态信息
*@param $data [array] 需要返回的数据
*
*/ class Response{
public function json($code,$message,$data){
$result = array(
"code" => $code,
"message" => $message,
"data" => $data
);
return json_encode($result);
}
}

response.class.php是一个最简单的返回json格式数据的类,在下面的课程中我们会进一步对其进行完善。

下面贴出接口文件代码:

returndata.php

<?php
require "response.class.php"; //引入返回信息类 //准备返回数据
$code = 200;
$message = "信息请求成功";
$data = array(
"name" => "ruanwnewu",
"sex" => "1",
"age" => "28",
"exp" => array(
"2012" => "北京瑞泰新",
"2013" => "兄弟连",
"2014" => "木蚂蚁科技"
)
); //实例化response类
$response = new Response; //返回数据
echo $response -> json($code,$message,$data);

请求returndata.php接口返回的数据如下图所示:

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAARMAAAEQCAIAAAAcXwdBAAAgAElEQVR4nO19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CaVOOXCUuTCKxt4HhPchggd9nxG+jwBfkETy5W2prvbte2PMYdhDNbXv8fIc2CV8r8TXnr+2k/0BYw5DXaM+DXWBMYeBIRgYcxgYgoAxh4EhCBhzGBiCgDGHgSEIGHMYGIKAMYeBIQgYcxgYgoAxh4EhCBhzGBiCgDGHgSEIGHMYGIKA26HfLAAAACxJREFUMYeBIQgYcxgYgoAxh4EhCBhzGBiCgDGHgSEIGHMYGIKAMYeBIQj+PwWxEBLVI2wWAAAAAElFTkSuQmCC" alt="" />

这样就完成了一个最基本的,封装好的json数据通信接口。

2-2 PHP生成XML数据 (12:02)

生成XML格式数据一般有三种方法:

  • 拼接字符串
  • domDocument
  • simpleXML

在这里我只讲解第一种方法生成XML数据的方法。上代码:

producexml.php

<?php
header('Content-Type:text/xml');
$xml = '<?xml version="1.0" encoding="utf-8" ?>';
$xml .= '<res>';
$xml .= '<code>404</code>'."\r\n";
$xml .= '<message>数据返回成功</message>'."\r\n";
$xml .= '<data>'."\r\n";
$xml .= '<name>软文无</name>'."\r\n";
$xml .= '<sex>1</sex>'."\r\n";
$xml .= '<age>28</age>'."\r\n";
$xml .= '</data>';
$xml .= '</res>';
echo $xml;

2-3 XML方式封装通信接口 (17:50)

上代码:

<?php

/**
 *description 用于返回指定数据格式的类
 *@param $code [int] 返回的状态码
 *@param $message [string] 返回的状态信息
 *@param $data [array] 需要返回的数据
 */ class Response{
    public function json($code,$message,$data){
        $result = array(
                "code" => $code,
                "message" => $message,
                "data" => $data
            );
        return json_encode($result);
    }
    
    public function xml($code,$message,$data){
        $result = array(
                "code" => $code,
                "message" => $message,
                "data" => $data
            );
        header('Content-Type:text/xml');
        $xml = "<?xml version='1.0' encoding='UTF-8'?>\n";
        $xml .= "<root>";
        $xml .= self::encodeXml($result);
        $xml .= "</root>";
        return $xml;
    }
    
    /**
     *将数据解析为XML字符串
     */
    
    public static function encodeXml($data){
        $attr = $xml = "";
        foreach($data as $key => $value){
                if(is_numeric($key)){
                    $attr = " id='{$key}'";
                    $key = "item";
                }
                $xml .= "<{$key}{$attr}>";
                $xml .= is_array($value)?self::encodeXml($value):$value;
                $xml .= "</$key>";
        }
        return $xml;
    }
    
}

同样用returndata.php调用该接口:

<?php
require "response.class.php"; //引入返回信息类 //准备返回数据
$code = 200;
$message = "信息请求成功";
$data = array(
"name" => "ruanwnewu",
"sex" => "1",
"age" => "28",
"exp" => array(
"2012" => "北京瑞泰新",
"2013" => "兄弟连",
"2014" => "木蚂蚁科技"
)
); //实例化response类
$response = new Response; //返回数据
echo $response -> xml($code,$message,$data);

得到如下图所示的XML文件结果

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXgAAAGWCAIAAAD9sQ8DAAAgAElEQVR4nO2dy3WsOBCGicgBEEYHQQJOYEJorxyFj3cdgNd37U2H4CA0Cx56lV406hbwfeeeM2MQaoGkn5KEqrp/AACV6V5dAAA4PggNAFQHoQGA6iA0AFAdhAYAqoPQAEB1EBoAqA5CAwDVQWgAoDoIDQBUB6EBgOogNABQHYQGAKqD0ABAdRAaAKgOQgMA1UFoAKA6CA0AVAehAYDqHF1ovt/furf371cXA+AlNNP+I0Lz/f7WXT7yjzfKx6XrUuUVq+PjEq6i7/c36dzHJf1kYtlaqdY95O/3t65L/kJh+yttroHnkNdynIv935ZKEyuh/SzdsgWqUs49VMFupeZV8lNkIN3+5cIGKytVi/L5qEXz/f4mlvH7/S3Zlj8unX+DHxfdCcYEwSKPHUafDpUlg2SnNetbJ44Kzff7xX0EYwnfvxPtJqcNrm2AU8V8pJ5VIP/pmXv1MjWdqcZC6Ay/vz/e37y6/fCemJTh2/u3VWF+5UkNOdr4nSysm/9+f+veLh+Z9THdWIbKRWow8RgzXhOFpNr/0iKtp2j9YQpsodDMjSpRyFHvzRaY/WQ8qTFlZmp3b6Hq+Lh0b29vZUKTKmWo0OaTMWQgpQh2W/K7kfEQ0lh3lrwo9FbVZ6KPa75h93ciPSPy5AMNzy5BqDz6Ibut/O392+uvfg3rHhKqXaH8y09l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k1oKGSFN/i8/qXSs+oEUIs2vqPJimpgRyxQSplKNPwKQ6HFJvKXt8X0AFCHJoRm06gGANAcLQjNtlENAKA5WhAaADg4CA0AVAehAYDqIDQAUB2EBgCqg9AAQHUQGgCoDkIDANV5htA848NfAh4ANMwThOYJH/7ihxygaaoLTTSqwVYgNABNU1torH3Z0+bp/ud33JMdCmYg7KgOJggHPACAVthMaHKiGrj+ZWJuZQzHetEEEaHBvwxAIzwuNPlRDbTQGEaHF+rAPZJMoIJDJzzmAbTBeqEpjmpgDJ2MWEpf/nhnMVK+bhkJlErO0eADGOC1rBSaNVENokLzZaYzDyYTKJU7GUxUA4AXsYVFkxnVIFtoZoPl8+eekUApLBqAxtlwjiYV1UAUmsgUzJQsmUD5AQ8mmKMBaINKq07RqAZOnMnHVp2UUkLAg/E6Vp0A2qDOdzSBqAay0CjlfiazIoEX8AAA2qGK0BDVAABMaggNUQ0AwAI3EQBQHYQGAKqD0ABAdRAaAKgOQgMA1UFoAKA6CA0AVAehAYDqIDQAUB2EBgCqg9AAQHUQGgCoDkIDANVBaACgOggNAFQHoQGA6iA0AFAdhAYAqoPQAEB1EBoAqM7/03emDD1CpoYAAAAASUVORK5CYII=" alt="" />

2-4 综合方式封装通信数据方法 (11:15)

将两种封装方法综合起来,并能够根据请求的参数来返回指定格式的数据,上代码:

完善后的response类

<?php

/**
*description 用于返回指定数据格式的类
*@param $code [int] 返回的状态码
*@param $message [string] 返回的状态信息
*@param $data [array] 需要返回的数据
*/ class Response{
public function show($code,$message,$data,$type="json"){
if($type == "json"){
$this->json($code,$message,$data);
}else{
$this->xml($code,$message,$data);
}
}
public function json($code,$message,$data){
$result = array(
"code" => $code,
"message" => $message,
"data" => $data
);
return json_encode($result);
} public function xml($code,$message,$data){
$result = array(
"code" => $code,
"message" => $message,
"data" => $data
);
header('Content-Type:text/xml');
$xml = "<?xml version='1.0' encoding='UTF-8'?>\n";
$xml .= "<root>";
$xml .= self::encodeXml($result);
$xml .= "</root>";
return $xml;
} /**
*将数据解析为XML字符串
*/ public static function encodeXml($data){
$attr = $xml = "";
foreach($data as $key => $value){
if(is_numeric($key)){
$attr = " id='{$key}'";
$key = "item";
}
$xml .= "<{$key}{$attr}>";
$xml .= is_array($value)?self::encodeXml($value):$value;
$xml .= "</$key>";
}
return $xml;
} }

未完待续。。。

上一篇:Chromium源码--视频播放流程分析(拨开云雾)


下一篇:JAVA反射机制基础概念