From cfa143a8a01f6549c5709b7459901f5ffaf65aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Fri, 13 Mar 2015 11:08:21 +0800 Subject: [PATCH] =?UTF-8?q?Updated=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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/接收消息与回复.md b/接收消息与回复.md index c6cc777..cb52e5a 100644 --- a/接收消息与回复.md +++ b/接收消息与回复.md @@ -11,6 +11,8 @@ $wechat->on('message', string $messageType, callable $callback); // 只监听指 - `$messageType` string, 指定要处理的消息类型,ex:`image` - `$callback` callable, 回调函数,closure匿名函数,或者一切可调用的方法或者函数 +`$callback` 接收一个参数:`$message` 为用户发送的消息对象,你可以访问[请求消息的所有属性]((https://github.com/overtrue/wechat/wiki/%E6%B6%88%E6%81%AF%E7%9A%84%E4%BD%BF%E7%94%A8#%E8%AF%B7%E6%B1%82%E6%B6%88%E6%81%AF%E7%9A%84%E5%B1%9E%E6%80%A7)),比如:`$message->FromUserName` 得到发送消息的人的 `openid`,`$message->MsgType` 获取消息的类型如 `text` 或者 `image` 等,更多请参考:[请求消息的属性](https://github.com/overtrue/wechat/wiki/%E6%B6%88%E6%81%AF%E7%9A%84%E4%BD%BF%E7%94%A8#%E8%AF%B7%E6%B1%82%E6%B6%88%E6%81%AF%E7%9A%84%E5%B1%9E%E6%80%A7) + example: ```php @@ -19,7 +21,7 @@ use Overtrue\Wechat\Services\Message; // 监听所有类型 $wechat->on('message', function($message) { - return Message::make('text')->content('您好!'); + return Message::make('text')->content('您好!'.$message->FromUserName); }); // 监听指定类型