qiqizjl / Think Wechat
Licence: mit
easywechat for thinkphp support
Stars: ✭ 250
Projects that are alternatives of or similar to Think Wechat
Crmeb wechatminiprogram
CRMEBv2.6以客户管理为中心+电商营销系统,微信小程序商城,带分销、秒杀、积分、优惠券等功能
Stars: ✭ 158 (-36.8%)
Mutual labels: thinkphp, wechat, weixin
Weixin Java Cp Demo
基于Spring Boot 和 WxJava 实现的微信企业号/企业微信 后端Demo
Stars: ✭ 175 (-30%)
Mutual labels: wechat, weixin
Wei
微信服务号裂变引擎,提供一套简单明了的DSL,快速配置和接入服务号裂变。 wechat fission platform, for technological dimensionality reduction.
Stars: ✭ 177 (-29.2%)
Mutual labels: wechat, weixin
Go Workwx
a sensible Work Weixin(企业微信, Wechat Work) SDK for Go
Stars: ✭ 181 (-27.6%)
Mutual labels: wechat, weixin
Weixin Popular
微信SDK JAVA (公众平台、开放平台、 商户平台、 服务商平台)
Stars: ✭ 2,384 (+853.6%)
Mutual labels: wechat, weixin
Wepush
专注批量推送的小而美的工具,目前支持:模板消息-公众号、模板消息-小程序、微信客服消息、微信企业号/企业微信消息、阿里云短信、阿里大于模板短信 、腾讯云短信、云片网短信、E-Mail、HTTP请求、钉钉、华为云短信、百度云短信、又拍云短信、七牛云短信
Stars: ✭ 2,597 (+938.8%)
Mutual labels: wechat, weixin
Wechatplugin Macos
No description or website provided.
Stars: ✭ 13,280 (+5212%)
Mutual labels: wechat, weixin
Cleanupwechatzombiefans
auto.js脚本,Android自动化,清理微信僵尸粉
Stars: ✭ 155 (-38%)
Mutual labels: wechat, weixin
Wechat Request
🚀⚡️基于Promise实现微信小程序http请求,轻便,小巧,api友好,功能丰富
Stars: ✭ 156 (-37.6%)
Mutual labels: wechat, weixin
Wxread Webautoreader
微信读书自动阅读器,全自动刷阅读时长,轻轻松松冲顶霸榜,您的微读挂机好帮手
Stars: ✭ 138 (-44.8%)
Mutual labels: wechat, weixin
Wechat Django
WeChat-Django旨在为接入微信公众平台的django开发者提供便捷的微信功能封装及最基本的后台管理支持
Stars: ✭ 143 (-42.8%)
Mutual labels: wechat, weixin
Wechat
weixin/wechat/微信公众平台/微信企业号/微信商户平台/微信支付 go/golang sdk
Stars: ✭ 2,330 (+832%)
Mutual labels: wechat, weixin
thinkphp-wechat
微信SDK For ThinkPHP 5.1 基于overtrue/wechat
框架要求
ThinkPHP5.1(中间件要求支持ThinkPHP5.1.6+)
安装
composer require naixiaoxin/think-wechat
配置
-
修改配置文件 修改项目根目录下config/wechat.php中对应的参数
-
每个模块基本都支持多账号,默认为 default。
使用
接受普通消息
新建一个Controller,我这边用的是Note
<?php
namespace app\wechat\controller;
use think\Controller;
class Note extends Controller
{
public function index()
{
// 先初始化微信
$app = app('wechat.official_account');
$app->server->push(function($message){
return 'hello,world';
});
$app->server->serve()->send();
}
}
获得SDK实例
使用facade
use Naixiaoxin\ThinkWechat\Facade;
$officialAccount = Facade::officialAccount(); // 公众号
$work = Facade::work(); // 企业微信
$payment = Facade::payment(); // 微信支付
$openPlatform = Facade::openPlatform(); // 开放平台
$miniProgram = Facade::miniProgram(); // 小程序
$openWork = Facade::openWork(); // 企业微信第三方服务商
$microMerchant = Facade::microMerchant(); // 小微商户
以上均支持传入自定义账号:例如
$officialAccount = Facade::officialAccount('test'); // 公众号
以上均支持传入自定义账号+配置(注:这里的config和配置文件中账号的格式相同):例如
$officialAccount = Facade::officialAccount('',$config); // 公众号
Oauth登录中间件(ThinkPHP5.1.6+)
使用中间件情况下,config的oauth.callback可以随便写~,反正是直接获取了当前URL
\think\facade\Route::rule('user','usere')->middleware(\Naixiaoxin\ThinkWechat\Middleware\OauthMiddleware::class);
上面的路由定义了 /user 是需要微信授权的,那么在这条路由的回调 或 控制器对应的方法里, 你就可以从 session('wechat_oauth_user_default') 拿到已经授权的用户信息了。
关于ThinkPHP5.1的中间件使用方法不在叙述,详情可以查看官方文档
中间件参数说明
由于ThinkPHP中间件只支持一个参数,所以以:
做分割
支持传入account账号别名以及scope类型
若不传入account
,会使用default
账号
若不传入scope
,会使用配置文件中的oauth.scope
支持一下两种方式
default:snsapi_base
snsapi_base
HOOK
你可以监听相应的事件,并对事件发生后执行相应的操作。
- OAuth授权
wechat_oauth
// 该事件有以下属性
$params['user']; // 同 session('wechat_oauth_user_default') 一样
$params['is_new']; // 是不是新的会话(第一次创建 session 时为 true)
更多 SDK 的具体使用请参考:https://easywechat.com
参考项目
License
MIT
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].