No official account required, no need to install enterprise WeChat client, low-cost push message solution
There is also Dcat-Admin version
Inspired by Server sauce, here is just a simple implementation.
The current version supports flexible settings
in addition
composer require asundust/wechat-work-push
'wechat-work-push' => [
'enable' => true,
// 'config_table' => 'wechat_work_push_configs', // 自定义配置表表名,可不填写,默认wechat_work_push_configs
// 'user_table' => 'wechat_work_push_users', // 自定义用户表表名,可不填写,默认wechat_work_push_users
// 'middleware' => 'web', // 自定义中间件组,可不填写,默认web
],
php artisan migrate
php artisan admin:import wechat-work-push
The following menu will be generated
After creation, copy [AgentId] and [Secret] and go to [Enterprise WeChat Application Message] - [Default Configuration] in the background of the website to fill in the corresponding column.
Enter the [My Business] page, scroll to the bottom, you can see the business ID, copy and fill it in the corresponding column, remember to save.
If it is a user-defined enterprise, remember to edit the user to fill in the corresponding three columns.
You can send test messages in the list. If Enterprise WeChat receives the message, it will be successful.
Enter [My Business] - [WeChat Plug-in], scroll down to scan the QR code, and follow it to receive push messages (you may need to download Enterprise WeChat and bind WeChat first). At this time, Enterprise WeChat and WeChat should messages can be received at the same time.
Set the enterprise WeChat to not receive messages and WeChat to receive messages.
[Enterprise WeChat APP]-[Three horizontal lines in the upper left corner]-[Gear settings in the lower right corner]-[New message notification]-[Only receive messages in Enterprise WeChat]-[App Message] Close
If there are multiple corporate identities, [Enterprise WeChat APP]-[Three horizontal lines in the upper left corner]-[Gear settings in the lower right corner]-[New message notification]-[Other corporate message reminders]-Select the company name you applied for and change it to [ Only receive special reminder messages] or [No reminder] - and then switch back to your commonly used corporate messages.
Then send the test notification, there should be no problem.
The tutorial on setting up message notifications here is wrong. If you have any questions, please contact me.
If you encounter problems, you can send a test message to the application you just created (select [Application Management]-[Self-Build]-[Application Name]-[Function]-[Send Message]).
In addition, if the interface request is normal, the corporate WeChat receives the message normally, but the personal WeChat cannot receive the message.
PC backend management terminal: Go to [My Business] - [WeChat Plug-in], scroll to the bottom, and check [Allow members to receive and reply to chat messages in the WeChat plug-in]
Also check the above-mentioned [Only receive messages in corporate WeChat] related settings
The default route supports get
and post
. Remember to add push/*
in except
in VerifyCsrfToken
to support post
interface requests.
The interface address is http://{www.abc.com}/push/{推送密钥}
, the title
is not required to be empty, the content is content
does not need to be passed, the link is url
is not required to be passed, and the link title is url_title
but is not required to be passed. Example: The get
address is http://{www.abc.com}/push/我是密钥?title=测试标题&content=测试内容&url=https://www.baidu.com&url_title=我是百度的测试链接
Passing in an illegal url
may cause the sending request to time out. For unknown reasons, it is recommended to test it yourself.
AsundustWechatWorkPushHttpTraitsWechatWorkPushSendMessageTrait
.defaultSend()
, and use the custom configuration to send send()
. Please refer to the method for details. If you think this project has saved you time, you might as well support it!
The MIT License (MIT)