承接 al-saloul/msegat 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

al-saloul/msegat

Composer 安装命令:

composer require al-saloul/msegat

包简介

This is a Laravel package for Msegat. Its goal is to remove the complexity

README 文档

README

This is a Laravel package that integrates with the Msegat SMS service. It simplifies the process of sending SMS messages through the Msegat API by providing an easy-to-use wrapper for Laravel applications.

Features

  • Send SMS messages easily using the Msegat API.
  • Configurable credentials (username, API key, sender name) through the .env file.
  • Designed specifically for Laravel applications.

Requirements

  • Laravel: 6 or higher
  • PHP: 7 or higher

Installation

To install the package, use Composer:

composer require al-saloul/msegat

Publish Configuration

To publish the configuration file, use the following command:

php artisan vendor:publish --provider="Alsaloul\Msegat\MsegatServiceProvider"

This will create a configuration file named msegat.php in your config folder.

Configuration

Add the following environment variables to your .env file:

MSEGAT_BASEURL="https://www.msegat.com"
MSEGAT_USERNAME=your_msegat_username
MSEGAT_API_KEY=your_msegat_api_key
MSEGAT_USER_SENDER=your_msegat_sender_name

Alternatively, you can directly edit the config/msegat.php file to set the required configuration.

Usage

To send an SMS message, use the Msegat facade:

use Alsaloul\Msegat\Msegat;

$response = Msegat::sendMessage('966123456789', 'Hello, this is a test message!');

if ($response['code'] === '1') {  
    echo "Message sent successfully!";
} else {
    echo "Failed to send message.";
}

Methods

Msegat::sendMessage($numbers, $message)

  • $numbers: The phone numbers to send the message to, separated by commas. (e.g., 96651xxxxxxx,96652xxxxxxx)
  • $message: The content of the message.

This method will send the message to the given numbers using the Msegat API.

Msegat::data($numbers, $message)

This method generates the JSON payload required for sending SMS messages. It's used internally by the sendMessage() method.

Examples

Sending a Single Message

Msegat::sendMessage('9665xxxxxxxx', 'Hello from Msegat!');

Sending Multiple Messages

$numbers = '96651xxxxxxx,96652xxxxxxx';
$message = 'This is a broadcast message.';

$response = Msegat::sendMessage($numbers, $message);

Handling Errors

If credentials or required parameters are not set, exceptions will be thrown:

try {
    Msegat::sendMessage('966123456789', 'Testing error handling.');
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}

Status Code and Messages

  • 1 - Success

  • M0000 - Success

  • M0001 - Variables missing

  • M0002 - Invalid login info

  • M0022 - Exceed number of senders allowed

  • M0023 - Sender Name is active or under activation or refused

  • M0024 - Sender Name should be in English or number

  • M0025 - Invalid Sender Name Length

  • M0026 - Sender Name is already activated or not found

  • M0027 - Activation Code is not Correct

  • 1010 - Variables missing

  • 1020 - Invalid login info

  • 1050 - MSG body is empty

  • 1060 - Balance is not enough

  • 1061 - MSG duplicated

  • 1064 - Free OTP , Invalid MSG content you should use "Pin Code is: xxxx", "Verification Code: xxxx" or upgrade your account and activate your sender to send any content

  • 1110 - Sender name is missing or incorrect

  • 1120 - Mobile numbers is not correct

  • 1140 - MSG length is too long

  • M0029 - Invalid Sender Name - Sender Name should contain only letters, numbers and the maximum length should be 11 characters

  • M0030 - Sender Name should ended with AD

  • M0031 - Maximum allowed size of uploaded file is 5 MB

  • M0032 - Only pdf,png,jpg and jpeg files are allowed!

  • M0033 - Sender Type should be normal or whitelist only

  • M0034 - Please Use POST Method

  • M0036 - There is no any sender

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature/new-feature).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature/new-feature).
  5. Create a new Pull Request.

Support

If you have any questions or issues, feel free to open an issue on the GitHub repository or contact the author via email at eng.alsaloul.mohammed@gmail.com.

al-saloul/msegat 适用场景与选型建议

al-saloul/msegat 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.59k 次下载、GitHub Stars 达 20, 最近一次更新时间为 2024 年 09 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 al-saloul/msegat 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 al-saloul/msegat 我们能提供哪些服务?
定制开发 / 二次开发

基于 al-saloul/msegat 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2.59k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 41
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 20
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-30