tanshiqi / laravel-wechat

微信公众平台 Laravel SDK
MIT License
26 stars 14 forks source link

本项目已停止开发

微信公众平台 Laravel SDK

使用帮助

0、说明

用 Laravel Facade 封装了 dodgepudding/wechat-php-sdk,目前只添加了 wechat.class 官方API类库,尽量做到及时更新,还未做全部测试,欢迎提交issue。

1、安装

请先确认已经安装Composer. 编辑 composer.json 文件,然后加入 atan/wechat.

"require": {
    "atan/wechat": "dev-master"
}

更新包 composer update

需要添加以下服务到系统。

打开 app/config/app.php , 在'providers' 下添加:

'Atan\Wechat\WechatServiceProvider',

'aliases' 下添加:

'Wechat' => 'Atan\Wechat\Facades\Wechat',

执行 php artisan config:publish atan/wechat ,然后修改 app/config/packages/atan/wechat 中的配置文件 wechat.php

把微信公众号的 'token', 'encodingaeskey', 'appid', 'appsecret' 改为对应的。

2、使用

// 获取用户列表
Route::get('/users', function(){
    return Wechat::getUserList();
});

// 回复文本消息
Route::post('/', function(){
    $weObj = new Atan\Wechat\Wechat();
    $type = $weObj->getRev()->getRevType();
    $weObj->text("hello, it's wechat")->reply();
});

3、主要功能

4、被动接口方法

5、主动接口方法:

6、环境

PHP >= 5.4 Laravel >= 4.2

7、License

This is free software distributed under the terms of the MIT license
感谢 dodgepudding/wechat-php-sdkhuanghua581/laravel-wechat-sdk