PHP code example of zodream / wechat
1. Go to this page and download the library: Download zodream/wechat library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zodream / wechat example snippets
'wechat' => [
'appid' => '',
'token' => '',
'aes_key' => '',
'secret' => '',
'redirect_uri' => '',
'platform' => [ // 第三方平台配置
'component_appid' => '',
'aes_key' => '',
'token' => '',
'component_appSecret' => ''
]
]
(new Menu())->menuList();
(new Menu())->create(
MenuItem::menu(MenuItem::name('网址')->setUrl('http://zodream.cn'))
->setMenu(
MenuItem::menu(MenuItem::name('点击')->setKey(1))
->setMenu(MenuItem::name('点击')->setKey(1))
)
->setMenu(MenuItem::name('查看')->setMediaId('132123123'))
);
(new Menu())->deleteMenu();
$message = new Message();
return $message->on([EventEnum::ScanSubscribe, EventEnum::Subscribe],
function(Message $message, MessageResponse $response) {
$response->setText('谢谢关注!');
})->on(EventEnum::Message, function(Message $message, MessageResponse $response) {
$response->setText(sprintf('您的消息是: %s', $message->content));
})->on(EventEnum::UnSubscribe, function(Message $message, MessageResponse $response) {
$response->setText('取消关注');
})->on(EventEnum::Click, function(Message $message, MessageResponse $response) {
$response->setText(sprintf('您点击了 %s', $message->eventKey));
})->run();