yvesniyo / intouch-sms
这是一个php库,帮助开发者集成短信服务,通过来自卢旺达的IntouchSms网关
v5.0
2021-03-31 15:13 UTC
Requires
- php: ^7.4
- guzzlehttp/guzzle: ^7.2
Requires (Dev)
- composer/composer: ^1.10
- dealerdirect/phpcodesniffer-composer-installer: ^0.6.2
- ergebnis/composer-normalize: ^2.5
- hamcrest/hamcrest-php: ^2
- mockery/mockery: ^1.3
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/extension-installer: ^1
- phpstan/phpstan: ^0.12.25
- phpstan/phpstan-mockery: ^0.12.5
- phpstan/phpstan-phpunit: ^0.12.8
- phpunit/phpunit: ^9.1
- psy/psysh: ^0.10.4
- slevomat/coding-standard: ^6.3
- squizlabs/php_codesniffer: ^3.5
- vimeo/psalm: ^3.11
README
这是一个php库,帮助开发者集成短信服务,通过来自卢旺达的IntouchSms网关
安装
使用Composer将此包作为依赖项安装。
composer require yvesniyo/intouch-sms
用法
这是文档
use Yvesniyo\IntouchSms\SmsSimple; /** @var \Yvesniyo\IntouchSms\SmsSimple */ $sms = new SmsSimple(); $sms->recipients(["250780588642","0720710379"]) ->message("Hello world") ->sender("intouchSenderId") ->username("intouchUsername") ->password("intouchPassword") ->apiUrl("www.intouchsms.co.rw/api/sendsms/.json") ->callBackUrl(""); print_r($sms->send());
这段代码运行良好,但是它确实调用了某些静态参数,例如senderId、Username、Password、ApiUrl和CallbackUrl。我们可以通过创建一个名为Sms的新类来扩展SmsAbstract来解决此问题
class Sms extends SmsAbstract { public function __construct() { parent::__construct(); // } public function configSender(): string { return "intouchSenderId"; } public function configUsername(): string { return "intouchUsername"; } public function configPassword(): string { return "intouchPassword"; } public function configApiUrl(): string { return "www.intouchsms.co.rw/api/sendsms/.json"; } public function configCallBackUrl(): string { return ""; } public static function QuickSend($recipients, String $message, String $senderId = null) { $sms = new Sms(); $sms->requiredData($recipients, $message, $senderId); return $sms->send(); } }
创建此类后,现在可以使用简单的代码,例如
$sms = new Sms(); // first parameter is recipients and second one is message $sms->requiredData(["250780588642","0720710379"], "wassup"); print_r($sms->send());
注意:对于那些不使用Composer的人,请记住添加
include_once("../vendor/autoload.php");
贡献
欢迎贡献!在向本项目贡献之前,请熟悉CONTRIBUTING.md。
要开发此项目,您需要PHP 7.4或更高版本,Composer,
在本地克隆此存储库后,执行以下命令
cd /path/to/repository
composer install
现在,您已经准备好开发了!
版权和许可证
yvesniyo/intouch-sms库是免费且不受限制的软件,已发布到公共领域。有关更多信息,请参阅UNLICENSE。