From d50333cfee3bcf3abdf37e6480e059bfe32d8e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Tue, 10 Feb 2015 23:14:12 +0800 Subject: [PATCH] =?UTF-8?q?Created=20=E6=8E=A5=E6=94=B6=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=B8=8E=E5=9B=9E=E5=A4=8D=20(markdown)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 接收消息与回复.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 接收消息与回复.md diff --git a/接收消息与回复.md b/接收消息与回复.md new file mode 100644 index 0000000..81892e6 --- /dev/null +++ b/接收消息与回复.md @@ -0,0 +1,33 @@ + ```php + $wechat->on('message', callable $callback); // 全部类型 + // or + $wechat->on('message', string $messageType, callable $callback); // 只监听指定类型 + ``` + + 参数说明 + + - `$messageType` string, 指定要处理的消息类型,ex:`image` + - `$callback` callable, 回调函数,closure匿名函数,或者一切可调用的方法或者函数 + + example: + + ```php + + use Overtrue\Wechat\Services\Message; + + // 监听所有类型 + $wechat->on('message', function($message) { + return Message::make('text')->content('您好!'); + }); + + // 监听指定类型 + $wechat->on('message', 'image', function($message) { + return Message::make('text')->content('我们已经收到您发送的图片!'); + }); + + $result = $wechat->serve(); + + echo $result; + ``` + +关于更多消息内容请参考: \ No newline at end of file