Discuz移动接口原理简介
来源:互联网 发布:linux fclose 退出 编辑:程序博客网 时间:2024/05/22 17:43
Discuz论坛内置提供针对移动端开发的json接口,下面根据源码进行一些分析。
入口 api/mobile/index.php
功能比较简单,指向source/plugins/mobile/mobile.php 或者check.php,check.php只有当类似$_GET['check'] == 'check'的情况下才运行,返回系统基本信息;其他请求均通过mobile.php接管。
mobile.php
mobile.php的基本思想是根据$_GET['module']以及$_GET['version']来调用相关的module文件,$_GET['version']参数可以做到版本兼容。
mobile/api/%version%/%module%.php
实现相当简单,根据需求设置$_GET['mod']等参数,然后将请求转到Discuz网页版页面,完成请求。同时,文件中定义mobile_api类。
mobile_api类
mobile_api类包含两个方法:common与output,common方法对应discuz的runhooks调用;output方法对应discuz的hookscriptoutput调用。
流程
Discuz调用runhooks时,调用mobile_plugin->common(),调用mobile_api->common()
Discuz在模板中调用hookscriptoutput()时,调用mobile_plugin->global_mobile(),调用mobile_api->output()
总结
Discuz大量使用$_G全局变量来保存系统运行过程中的结果,这为移动端内容输出提供便利,只需要在模板输出前截获$_G变量,然后根据需求从$_G变量中提取所需数据,并使用json格式返回。这就是Discuz移动端接口的基本实现方式。
- Discuz移动接口原理简介
- Discuz!NT原理
- Discuz论坛内置提供针对移动端开发的json接口/为什么需要自己的论坛不是saas服务
- Discuz! Passport 接口技术文档
- Discuz! Passport 接口技术文档
- Discuz!登录,注册,退出接口.
- discuz mobile 接口加载过程
- [转]Discuz 模板原理分析
- Discuz!伪静态原理分析
- discuz论坛用户密码加密原理
- 接口简介
- Discuz!注册接口.可以不用跳转到Discuz!页面.
- 接口原理
- [转]Discuz! Passport 接口技术文档
- Discuz! X2.5正式版门户文章接口
- discuz ucenter的用户注册接口函数
- discuz ucenter用户登录接口实例
- Discuz 迁移后数据接口配置
- java 多线程
- Spark1.6.1集群环境搭建——Standalone模式HA
- [BZOJ3675][Apio2014]序列分割(斜率优化dp)
- 【WLAN从入门到精通-基础篇】第1期——WLAN定义和基本架构
- 设计模式C++学习笔记之二(Bridge桥梁模式)
- Discuz移动接口原理简介
- github上传时出现error: src refspec master does not match any解决办法
- 概率图模型
- 两种方法证明积分中值定理_20160405
- Discuz!X/数据库操作方法
- ListView实现看新闻
- 分析linux内存管理机制
- 三大VR如何选择?小编带您深入浅出找不同
- 设计模式C++学习笔记之三(Iterator迭代器模式)