mirror of
https://github.com/w7corp/easywechat.git
synced 2025-01-22 11:32:08 +00:00
Created 接收消息与回复 (markdown)
parent
f81ec4cab8
commit
d50333cfee
33
接收消息与回复.md
Normal file
33
接收消息与回复.md
Normal file
@ -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;
|
||||
```
|
||||
|
||||
关于更多消息内容请参考:
|
Loading…
Reference in New Issue
Block a user