承接 advanta_africa/sms_api 相关项目开发

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

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

advanta_africa/sms_api

Composer 安装命令:

composer require advanta_africa/sms_api

包简介

A PHP package for sending SMS using Advanta Africa APIs

README 文档

README

Version

Overview

The Advanta Africa SMS API package provides a simple interface for sending SMS, checking SMS balance and retrieving delivery reports using the Advanta Africa SMS APIs. This package allows you to easily integrate SMS functionalities into your PHP applications.

Table of Contents

Installation

You can install this package via Composer. Run the following command:

composer require advanta_africa/sms_api

Usage

Configuration

To use the package, you need to provide the API credentials and the URL for the specific endpoint you want to interact with. You can pass the URL, API key, partner ID and sender ID directly when creating an instance of the package. These crednetials are accessible in your Advanta Africa SMS account. You can contact them for account creation

use AdvantaAfrica\SmsApi\SmsApi;

// Create an instance for sending SMS, OTP, and getting balance or delivery reports
$smsApi = new SmsApi('endpoint', 'apiKey', 'partnerId', 'senderId');

Sending SMS

To send a single SMS, you can use the sendSingleSmsPost method for POST requests or sendSingleSmsGet for GET requests. Both methods accept mobile numbers and a message. Optionally, you can pass timeToSend to schedule messages (or pass null if not being scheduled) and a hashed key = true when sending to hashed numbers.

POST Example

You can pass a single number or a comma separated set of numbers (Numbers can start with 07, 0 or 254):

$response = $smsApi->sendSingleSmsPost('07xxxxxxxxxx,07xxxxxxxxx', 'Your message here', 'timeToSend', null);

GET Example

$response = $smsApi->sendSingleSmsGet('07xxxxxxxxxxx', 'Your message here','timeToSend', null);

Send OTP Endpoint usage

When using the otp endpoint, you can use the same sendSingleSmsPost method for POST requests or sendSingleSmsGet for GET requests. This is the same endpoint for sending SMS to hashed numbers. You will need to pass hashed key and value true. If not passed, it will be treated as a regular mobile number.

POST Example

To send an SMS to a hashed mobile number using OTP endpoint:

$response = $smsApi->sendSingleSmsPost('xxxxxxxxx', 'Your message here', 'timeToSend', 'true');

To send to a regular number using OTP endpoint:

$response = $smsApi->sendSingleSmsPost('07xxxxxxxxxx', 'Your message here', 'timeToSend',null);

GET Example

To send an SMS to a hashed mobile number using OTP endpoint:

$response = $smsApi->sendSingleSmsGet('xxxxxxxxxx', 'Your message here', 'Your message here', 'true');

To send to a regular number using OTP endpoint:

$response = $smsApi->sendSingleSmsGet('07xxxxxxxxxx', 'Your message here', 'Your message here',null);

Sending Bulk SMS

To send multiple SMS messages in a single request, use the sendBulkSms method. This method requires an array of SMS details and is only available via POST.

Example

$smsList = [
    [
        'partnerID' => '12345',
        'apikey' => 'apiKey',
        'mobile' => '07xxxxxxxxxxxx',
        'message' => 'This is a test message',
        'shortcode' => 'xxxxxxxxxxxx'
    },
    [
        'partnerID' => '12346',
        'apikey' => 'apiKey',
        'mobile' => '07xxxxxxxxxxxx',
        'message' => 'This is a test message 2',
        'shortcode' => 'xxxxxxxxxxxx'
    ]
];

$response = $smsApi->sendBulkSms($smsList);

Getting Balance

To check your SMS balance, you can use the getBalancePost method for POST requests or getBalanceGet for GET requests.

POST Example

$balanceResponse = $smsApi->getBalancePost(); 

GET Example

$balanceResponse = $smsApi->getBalanceGet();

Getting Delivery Reports

To retrieve the delivery status of an SMS, you can use the getDeliveryStatusPost for POST requests or getDeliveryStatusGet for GET requests.

POST Example

$deliveryResponse = $smsApi->getDeliveryStatusPost('messageId');

GET Example

$deliveryResponse = $smsApi->getDeliveryStatusGet('messageId');

Endpoints

  • Sending Single SMS to 1 or multiple recipients: https://quicksms.advantasms.com/api/services/sendsms/
  • Sending single SMS to 1 or multiple recipients via OTP route or sending to hashed mobile numbers: https://quicksms.advantasms.com/api/services/sendotp
  • Sending Bulk SMS: https://quicksms.advantasms.com/api/services/sendbulk/
  • Getting Balance: https://quicksms.advantasms.com/api/services/getbalance/
  • Getting Delivery Report: https://quicksms.advantasms.com/api/services/getdlr/

Important Notes

  • For the Send SMS and Send OTP endpoints, both use the same methods (sendSingleSmsPost and sendSingleSmsGet), but they have different URLs and may require a hashed key for SMS requests sent to a hashed mobile number.
  • When scheduling messages, pass the time as a string that can be converted to a Unix timestamp. If not needed, simply omit it.
  • Ensure that the partnerId is always numeric.
  • Mobile numbers can start with 254,07 or 0 for new prefixes
  • When sending to hashed numbers, make sure the number before being hashed starts with 254xxxxxxxxxx

Author

Harold Kerry Omondi Email: haroldkerry@gmail.com

License

This package is licensed under the MIT License.

advanta_africa/sms_api 适用场景与选型建议

advanta_africa/sms_api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 10 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 advanta_africa/sms_api 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 28
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-08