mirror of
https://github.com/w7corp/easywechat.git
synced 2025-02-02 02:34:22 +00:00
初始化
parent
daa4e13135
commit
3ceec80741
26
配置与初始化.md
Normal file
26
配置与初始化.md
Normal file
@ -0,0 +1,26 @@
|
||||
本项目的用法目前网上其它SDK用法不同,这里只需要像下面这样配置一次完成:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Overtrue\Wechat\Wechat;
|
||||
|
||||
$options = [
|
||||
'appId' => 'Your app id',
|
||||
'secret' => 'Your secret'
|
||||
'token' => 'Your token',
|
||||
'encodingAESKey' => 'Your encoding AES Key' // optional
|
||||
];
|
||||
|
||||
$wechat = Wechat::make($options);
|
||||
|
||||
$server = $wechat->on('message', function($message){
|
||||
error_log("收到来自'{$message['FromUserName']}'的消息:" . $message['Content']);
|
||||
});
|
||||
|
||||
$result = $wechat->serve();
|
||||
|
||||
// 您可以直接echo 或者返回给框架
|
||||
echo $result;
|
||||
```
|
||||
`$wechat->serve()` 方法返回的值为字符串或者空,用于应答微信服务器的推送,消息或者事件等。
|
Loading…
Reference in New Issue
Block a user