jundayw/message

Integrates with SMS, DingTalk, and WeChat through a single API, and supports customizable channels.

Maintainers

Package info

github.com/jundayw/message

pkg:composer/jundayw/message

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-04-02 08:18 UTC

This package is auto-updated.

Last update: 2026-04-02 08:31:59 UTC


README

Message

Integrates with SMS, DingTalk, and WeChat through a single API, and supports customizable channels.

GitHub Tag Total Downloads Packagist Version Packagist PHP Version Support Packagist License

Table of Contents
  1. Installation
  2. Usage
  3. Contributing
  4. Contributors
  5. License

Installation

You can install the package via Composer:

composer require jundayw/message

[back to top]

Usage

SMS

method send: specify templateCode, templateParam, and signName explicitly (with a placeholder signName that gets

Message::channel('sms')->send(['136****5922'], [
    'templateCode'  => 'SMS_275***212',
    'templateParam' => [
        'code' => 123454,
    ],
    'signName'      => '${signName}',
], [
    'signName' => 'aliyun',
]);

Custom template sending:

uses a logical template name (e.g., 'demo') instead of the provider's template code

Message::channel('sms')->sendTemplate(['136****5922'], 'demo', [
    'code' => 234567,
]);

Service provider template number:

directly uses the provider's official template code (e.g., 'SMS_275***212')

Message::channel('sms')->sendTemplate(['136****5922'], 'SMS_275***212', [
    'code' => 345678,
]);

DingTalk

$message = Message::channel('dingtalk_robot')->send(['136****5922'], [
    'msgtype' => 'text',
    'text'    => [
        'content' => 'message.dingtalk_robot.send',
    ],
]);

Custom template sending:

return [
    'channels' => [
        'dingtalk_robot' => [
            'webhook'   => env('DINGTALK_ROBOT_WEBHOOK'),
            'secret'    => env('DINGTALK_ROBOT_SECRET'),
            'templates' => [
                'demo' => [
                    'msgtype' => 'text',
                    'text'    => [
                        'content' => '${content}',
                    ],
                ],
            ],
        ],
    ],
];
$message = Message::channel('dingtalk_robot')->sendTemplate(['136****5922'], 'demo', [], [
    'content' => 'message.dingtalk_robot.send',
    'at_all'  => true,
]);
$message = Message::channel('dingtalk_robot')->sendTemplate(['136****5922'], 'text', [
    'text' => [
        'content' => 'message.dingtalk_robot.send',
    ],
]);

WeChat

WechatMiniProgram

$message = Message::channel('wechat_mini_program')->send(['oDx1b*****C3o0'], [
    'template_id' => '1pNJGVRYV***ozu1AJKUlbGQ',
    'page'        => 'index',
    'data'        => [
        'thing1' => ['value' => '验证码'],
        'thing2' => ['value' => '登录验证'],
    ],
]);
$message = Message::channel('wechat_mini_program')->sendTemplate(['oDx1b*****C3o0'], '1pNJGVRYV***ozu1AJKUlbGQ', [
    'page' => '${page}',
    'data' => [
        'thing1' => ['value' => '${data.thing1}'],
        'thing2' => '登录验证',
    ],
], [
    'page' => 'page',
    'data' => [
        'thing1' => '验证码',
    ],
]);

WechatOfficialAccount

$message = Message::channel('wechat_official_account')->sendTemplate(['oDx1b*****C3o0'], '1pNJGVRYV***ozu1AJKUlbGQ', [
    'data' => [
        'thing1' => ['value' => '验证码'],
        'thing2' => '登录验证',
    ],
]);

WechatServiceAccount

$message = Message::channel('wechat_service_account')->sendTemplate(['oDx1b*****C3o0'], '1pNJGVRYV***ozu1AJKUlbGQ', [
    'page' => '${page}',
    'data' => [
        'thing1' => ['value' => '验证码'],
        'thing2' => '登录验证',
    ],
], [
    'page' => 'page',
]);

WeWork

$message = Message::channel('wework_robot')->send(['oDx1b*****C3o0'], [
    'msgtype' => 'text',
    'text'    => [
        'content' => 'message.wework_robot.send',
    ],
]);
$message = Message::channel('wework_robot')->sendTemplate(['oDx1b*****C3o0'], 'demo', [
    'text' => [
        'content' => '${content}',
    ],
], [
    'content' => 'content',
    'at_all'  => true,
]);

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

[back to top]

Contributors

Thanks goes to these wonderful people:

contrib.rocks image

Contributions of any kind are welcome!

[back to top]

License

Distributed under the MIT License (MIT). Please see License File for more information.

[back to top]