Code Monkey home page Code Monkey logo

think-wechat's Introduction

think-wechat

微信SDK For ThinkPHP 5.1, ThinkPHP 6.0 基于overtrue/wechat

框架要求

ThinkPHP >= 5.1

安装

composer require hectorqin/think-wechat

配置

  1. 修改配置文件 修改项目根目录下config/wechat.php中对应的参数

  2. 每个模块基本都支持多账号,默认为 default。

使用

接受普通消息

<?php

namespace app\index\controller;


use think\Controller;

class Wechat 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 Hectorqin\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); // 公众号

更多 SDK 的具体使用请参考:https://easywechat.com

License

MIT

think-wechat's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

blackgenerator

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.