2017 © Pedro Peláez
 

yii2-extension yii2-wechat

WeChat SDK for yii2, based on overtrue/easywechat

image

thanatosxia/yii2-wechat

WeChat SDK for yii2, based on overtrue/easywechat

  • Friday, June 29, 2018
  • by thanatos915
  • Repository
  • 1 Watchers
  • 3 Stars
  • 33 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 450 % Grown

The README.md

, (*1)

Wechat Sdk Extension for Yii 2


based on overtrue/wechat, (*2)

Latest Stable Version Total Downloads Latest Unstable Version, (*3)

安装

composer require thanatosxia/yii2-wechat

使用

添加配置到main.php/config.php, (*4)


'wechat' => [ 'class' => 'thanatos\wechat\Wechat', 'log' => [ 'level' => 'debug', 'permission' => '0777', 'file' => '@runtime/logs/wechat.log' ], 'app_id' => '', 'secret' => '', 'token' => '', /** * official 公众号 * miniProgram 小程序 * open 开放平台 * weWork 企业微信 * payment 微信支付 */ 'app_type' => '', ],

对接微信, (*5)

        $app = Yii::$app->wechat->app;

        $app->server->push(EventMessageHandle::class);

        $response = $app->server->serve();

        $response->send();

新建EventMessageHandle类, extends thanatos\wechat\MessageHandler, (*6)

class EventMessageHandle extends MessageHandler
{
    // 在执行处理之前会被执行,如果返回false则不继续执行
    public function beforeHandle()
    {

        return parent::beforeHandle();
    }

    // 默认的消息处理方法
    public function handleDefault()
    {
        $string = 123 . Yii::$app->user->id;
        return $string;
    }

    public function getUnionid()
    {
        return $this->wechatInfo->unionid;
    }

    // 处理用户关注事件
     public function eventSubscribe()
     {

     }

}

对于微信的时间推荐,可以在自定义的消息处理类中添加方法,来处理 如, (*7)

  • subscribe 对应的处理方法是 eventSubscribe
  • scan 对应的处理方法是 eventScan

The Versions

29/06 2018

dev-master

9999999-dev

WeChat SDK for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by thanatos

29/06 2018

1.1.1

1.1.1.0

WeChat SDK for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by thanatos

02/05 2018

1.1.0

1.1.0.0

WeChat SDK for yii2, based on overtrue/easywechat

  Sources   Download

MIT

The Requires

 

by thanatos