Skip to content

xutongtong/wechat

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wechat

可能是目前最优雅的微信 SDK 了

Build Status Latest Stable Version Latest Unstable Version Build Status Scrutinizer Code Quality Total Downloads

网上充斥着各种微信 SDK,但是找了一圈,发现没有一个想用,因为没有满足本项目存在后的各种优点:

  • 命名不那么乱七八糟;
  • 隐藏开发者不需要关注的细节;
  • 方法使用更优雅,不再那么恶心的使用恶心的命名譬如:getXML4Image...
  • 统一的错误处理,让你更方便的掌控异常;
  • 自定义缓存方式;
  • 符合 PSR-4 标准,你可以各种方便的与你的框架集成;
  • 高度抽象的消息类,免去各种拼json与xml的痛苦。

安装

环境要求:PHP >= 5.3.0

  1. 使用 composer:
composer require overtrue/wechat
  1. 手动安装

下载 最新版zip包 或者下载指定版本:https://github.com/overtrue/wechat/releases

然后引入根目录的autoload.php即可:

<?php

require "wechat/autoload.php"; // 路径请修改为你具体的实际路径

use Overtrue\Wechat\Wechat;
...

使用

基本使用

<?php

use Overtrue\Wechat\Wechat;

$options = [
    'appId'          => 'Your app id',
    'secret'         => 'Your secret'
    'token'          => 'Your token',
    'encodingAESKey' => 'Your encoding AES Key' // optional
];

$wechat = Wechat::make($options);

$server = $wechat->on('message', function($message){
    error_log("收到来自'{$message['FromUserName']}'的消息:{$message['Content']}");
});

$result = $wechat->serve();

// 您可以直接echo 或者返回给框架
echo $result;

文档

Wiki

TODO

  • 用户
  • 用户组
  • 客服
  • 监听事件与消息
  • 基本消息类型
  • 图文消息
  • 群发消息
  • 自定义菜单
  • Auth
  • Ticket
  • 二维码
  • 短链接

贡献代码

欢迎大家贡献代码,但请遵循PSR标准: https://github.com/php-fig/fig-standards/blob/master/accepted/ 谢谢!

License

MIT

About

可能是目前最优雅的微信 SDK 了

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%