2017 © Pedro Peláez
 

library mp-tools

image

rebie-kong/mp-tools

  • Sunday, February 5, 2017
  • by RebieKong
  • Repository
  • 1 Watchers
  • 0 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

# 微信公众号开发组件

### QuickStart

composer require rebie-kong/mp-tools, (*1)

// Hooker.php
class Hooker extends MpHook
{
    public function __construct()
    {
        parent::__construct();

        $function = new MpHookFunction(function(MessageBean $bean){
            if ($bean->content =='不理我'){
                return ResponseGainer::nullResult();
            }
            return ResponseGainer::genTextResult(sprintf("你发送的消息是:%s",$bean->content),$bean);
        });
        $this->hook(HookInterface::HOOK_MSG_TEXT,$function);
    }
}
// Controller.php
class Controller
{
    public function action(){
        $mpConfig = [];
        $hooker = new Hooker();
        $runner = new MpTask($hooker);

        $response = $runner->run($mpConfig['app_id'], $mpConfig['app_secret'], $mpConfig['token'],
            $mpConfig['aes_key']);
    }
}

上述代码实现了当用户发送文字信息时回复你发送的消息是:%s, (*2)

当发送不理我时不回复, (*3)

其他消息事件将会因为没有被hook而报告错误, (*4)

### Business Support

本组件仅许可非商业开源,如用于商用请联系开发者邮箱, (*5)

The Versions

05/02 2017

dev-master

9999999-dev

  Sources   Download

Apache-2.0

The Requires

 

by Avatar RebieKong

05/02 2017

1.1.0

1.1.0.0

  Sources   Download

Apache-2.0

The Requires

 

by Avatar RebieKong

04/02 2017

1.0.3

1.0.3.0

  Sources   Download

Apache-2.0

The Requires

 

by Avatar RebieKong

04/02 2017

1.0.2

1.0.2.0

  Sources   Download

Apache-2.0

The Requires

 

by Avatar RebieKong

03/02 2017

1.0.1

1.0.1.0

  Sources   Download

Apache-2.0

The Requires

 

by Avatar RebieKong

02/02 2017

1.0.0

1.0.0.0

  Sources   Download

Apache-2.0

The Requires

  • previewframework/utils *

 

by Avatar RebieKong