Updated 接收消息与回复 (markdown)

安正超 2015-03-13 11:08:21 +08:00
parent 04faa1a43c
commit cfa143a8a0

@ -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);
});
// 监听指定类型