ghasedaksms/php
Composer 安装命令:
composer require ghasedaksms/php
包简介
a package for use ghasedaksms api services in php programming
README 文档
README
Ghasedak PHP SDK
Easy-to-use SDK for implementing Ghasedak SMS API in your PHP projects.
Explore the docs »
Web Service Documents
·
REST API
.
Report Bug
·
Request Feature
Table of Contents
Install
The easiest way to install is by using Composer:
composer require ghasedaksms/php
Composer is a dependency manager for PHP which allows you to declare the libraries your project depends on, and it will manage (install/update) them for you. If you are not familiar with Composer, you can read its documentations and download it via getcomposer.org.
Alternatively you can download Ghasedak SDK from here and extract it in your project and follow the rest of the instructions below. Also there is an Example folder inside the package which you can use to understand the procedure.
Usage
To use the API, you need an API key. To get that you should have a Ghasedak account. Register and get your API key.
Then require the file autoload.php to get all classes and dependencies loaded.
require __DIR__ . '/vendor/autoload.php';
Create an instance from Ghasedak class with your API key:
$ghasedaksms = new GhasedaksmsApi('your_api_key');
Don't forget to change your_api_key with the key you have got from your Ghasedak account.
Send Single
$sendDate = new DateTimeImmutable('now'); $lineNumber = '3000****'; $receptor = '0912*******'; $message = 'test'; try { $response = $ghasedaksms->sendSingle(new SingleMessageDTO( sendDate: $sendDate, lineNumber: $lineNumber, receptor: $receptor, message: $message )); var_dump($response); } catch (Exceptions\GhasedakSMSException $e) { var_dump($e->getMessage()); }
Send Bulk
$sendDate = new DateTimeImmutable('now'); $lineNumber = '3000****'; $receptor = ['0912*******','0919*******']; $message = 'test'; try { $response = $ghasedaksms->sendBulk(new BulkMessageDTO( sendDate: $sendDate, lineNumber: $lineNumber, receptors: $receptor, message: $message )); var_dump($response); } catch (Exceptions\GhasedakSMSException $e) { var_dump($e->getMessage()); }
Send Pair To Pair
$sendDate = new DateTimeImmutable('now'); $lineNumber = '3000****'; $receptor1 = '0912*******'; $receptor2 = '0912*******'; $message1 = 'test1'; $message2 = 'test2'; try { $response = $ghasedaksms->sendPairToPair(new PairToPairMessageDTO( [ new SingleMessageDTO( sendDate: $sendDate, lineNumber: $lineNumber, receptor: $receptor1, message: $message1 ), new SingleMessageDTO( sendDate: $sendDate, lineNumber: $lineNumber, receptor: $receptor2, message: $message2 ) ] )); var_dump($response); } catch (Exceptions\GhasedakSMSException $e) { var_dump($e->getMessage()); }
Send OTP
$sendDate = new DateTimeImmutable('now'); try { $response = $ghasedaksms->sendOtp(new OtpMessageDTO( sendDate: $sendDate, receptors: [ new ReceptorDTO( mobile: '0912*******', clientReferenceId: '1' ) ], templateName: 'newOtp', inputs: [ new InputDTO( param: 'Code', value: 'value' ), new InputDTO( param: 'Name', value: 'value' ) ] )); var_dump($response); } catch (Exceptions\GhasedakSMSException $e) { var_dump($e->getMessage()); }
Send OTP With Params
$sendDate = new DateTimeImmutable('now'); try { $response = $ghasedaksms->sendOtpWithParams(new OtpMessageWithParamsDTO( sendDate: $sendDate, receptors: [ new ReceptorDTO( mobile: '0912*******', clientReferenceId: '1' ) ], templateName: 'newOtp', param1: 'param1', param2: 'param2' )); var_dump($response); } catch (Exceptions\GhasedakSMSException $e) { var_dump($e->getMessage()); }
Check SMS Status
try { $response = $ghasedaksms->checkSmsStatus(new CheckSmsStatusDTO( ids: ['246*****'], type: 1 )); var_dump($response); } catch (Exceptions\GhasedakSMSException $e) { var_dump($e->getMessage()); }
Get Account Information
try { $response = $ghasedaksms->getAccountInformation(); var_dump($response); } catch (Exceptions\GhasedakSMSException $e) { var_dump($e->getMessage()); }
Get Received SMSes
try { $response = $ghasedaksms->getReceivedSMSes( new GetReceivedSMSesDTO( lineNumber: '3000****' ) ); var_dump($response); } catch (Exceptions\GhasedakSMSException $e) { var_dump($e->getMessage()); }
Get Received SMSes Pagination
$startDate = new DateTimeImmutable('now'); $endDate = $startDate->modify('+3 days'); try { $response = $ghasedaksms->getReceivedSMSesPaging( new GetReceivedSMSesPagingDTO( lineNumber: '3000****', startDate: $startDate, endDate: $endDate, pageIndex: 0, pageSize: 10 ) ); var_dump($response); } catch (Exceptions\GhasedakSMSException $e) { var_dump($e->getMessage()); }
Get OTP Template Parameters
try { $response = $ghasedaksms->getOtpTemplateParameters( new GetOtpTemplateParametersDTO( templateName: 'newOtp' ) ); var_dump($response); } catch (Exceptions\GhasedakSMSException $e) { var_dump($e->getMessage()); }
License
Freely distributable under the terms of the MIT license.
ghasedaksms/php 适用场景与选型建议
ghasedaksms/php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.69k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 07 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「notification」 「sms-gateway」 「sms-api」 「Ghasedak」 「ghasedaksms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ghasedaksms/php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ghasedaksms/php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ghasedaksms/php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package makes it easy to send notifications via AfricasTalking with Laravel
Apple Push Notification & Feedback Provider
Throttle notifications on a per-channel basis
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
Simple javascript toast notifications
统计信息
- 总下载量: 2.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 25
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-21