4 Star 6 Fork 4

wext / wext-server-thinkphp3.2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

项目介绍

微信小程序组件 wext 服务端接入示例代码(ThinkPHP3.2版本)

本项目提供小程序会话SESSION方案


安装使用

环境要求

PHP >= 5.4,MySQL >= 5.6

支持Composer 如何安装Composer - composer中文文档

安装

  • 将代码 git clone 到web服务器根目录
  • 在代码根目录执行 composer install,安装依赖性的Composer组件
  • 导入 database/wext.sql 到数据库
  • 修改数据库配置文件 application/Common/Conf/db.php,修改对应的数据库地址(DB_HOST)、数据库名(DB_NAME)、数据库用户(DB_USER)和密码(DB_PWD)
  • 登陆微信小程序后台 https://mp.weixin.qq.com/,获取对应小程序的 AppID 和 AppSecret,修改小程序配置文件 application/Common/Conf/miniapp.php 中对应配置
  • 根据自身服务器环境配置小程序后台的request合法域名。

接口说明

用户登陆接口 /User/login

通过提交小程序用户登陆获得的code,换取并自动在DB中记录用户OPENID

用户资料更新接口 /User/UserUpdateInfo

用于更新微信用户信息


二次开发 & 扩展

二次开发示例

application/API/Controller 下新建一个控制器,命名为DemoController.class.php,内容如下

<?php
namespace API\Controller;

/**
 * 一个扩展示例
 * Class UserController
 * @package API\Controller
 */
class DemoController extends BaseController
{
    public function __construct()
    {
        parent::__construct();
    }

    public function test()
    {
        $this->SuccessResponse();
    }
}

访问项目地址 /Demo/test,将获得返回信息如下:

{"ret":1,"data":""}

常用函数说明(位于API/BaseController)

checkOnline - 检查会话是否正常,是否已经做了OPENID登陆

checkParams - 对提交参数的信息/提交方式/是否必须/非空进行检测,并作出反馈

SuccessResponse - 请求成功,符合期望时接口相应函数

ErrorResponse - 请求成功,不符合期望时接口相应函数

其他

本项目微信接口基于 EasyWechat 开发。

MIT License Copyright (c) 2018 wext-cc Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

微信小程序组件 wext 服务端接入示例代码(ThinkPHP3.2版本) 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/wext/wext-server-thinkphp3.2.git
git@gitee.com:wext/wext-server-thinkphp3.2.git
wext
wext-server-thinkphp3.2
wext-server-thinkphp3.2
master

搜索帮助