barretzhi/wechat

微信SDK

Maintainers

Details

github.com/barretzhi/wechat

Source

Installs: 22

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 2 402

4.0.0-beta.3 2017-09-23 08:29 UTC

README

EasyWeChat

📦 It is probably the best SDK in the world for developing Wechat App.

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

Special thanks to the generous sponsorship by:

68747470733a2f2f796f757361696c732e636f6d2f62616e6e6572732f6272616e642e706e67

68747470733a2f2f6f3064706c733172752e716e73736c2e636f6d2f6c617261766973742e636f6d2d6c6f676f2e706e67

687474703a2f2f7778312e73696e61696d672e636e2f6d773639302f3832623934666234677931666777616671333272306a32306e77306e777465722e6a7067

关注我的公众号我们一起聊聊代码怎么样?

Feature

  • 命名不那么乱七八糟;
  • 隐藏开发者不需要关注的细节;
  • 方法使用更优雅,不必再去研究那些奇怪的的方法名或者类名是做啥用的;
  • 自定义缓存方式;
  • 符合 PSR 标准,你可以各种方便的与你的框架集成;
  • 高度抽象的消息类,免去各种拼json与xml的痛苦;
  • 详细 Debug 日志,一切交互都一目了然;

Requirement

  1. PHP >= 7.0
  2. composer
  3. openssl 拓展
  4. fileinfo 拓展(素材管理模块需要用到)

SDK 对所使用的框架并无特别要求

Installation

注意!当前分支这 4.0 分支, 4.0 还没有发布,意味着你无法通过下面的命令来安装。如果你想尝鲜 4.0 可以将 4.0 换成 dev-master 安装。

composer require "overtrue/wechat:~4.0" -vvv

Usage

基本使用(以服务端为例):

<?php

use EasyWeChat\Factory;

$options = [
    'app_id'    => 'wx3cf0f39249eb0exxx',
    'secret'    => 'f1c242f4f28f735d4687abb469072xxx',
    'token'     => 'easywechat',
    'log' => [
        'level' => 'debug',
        'file'  => '/tmp/easywechat.log',
    ],
    // ...
];

$app = Factory::officialAccount($options);

$server = $app->server;
$user = $app->user;

$server->push(function($message) use ($user) {
    $fromUser = $user->get($message['FromUserName']);

    return "{$fromUser->nickname} 您好!欢迎关注 overtrue!";
});

$server->serve()->send();

更多请参考 https://easywechat.com/

Documentation

强烈建议看懂微信文档后再来使用本 SDK。

Integration

Laravel 5 拓展包: overtrue/laravel-wechat

Contribution

Contribution Guide

License

MIT