yoqut / sms
PHP应用程序的短信组件。
该包的规范仓库似乎已丢失,因此该包已被冻结。
v2.2
2017-06-12 19:43 UTC
Requires
- php: >=5.3.3
- yoqut/smpp: ~1.1
Requires (Dev)
- phpspec/phpspec: ~2.1
This package is not auto-updated.
Last update: 2020-02-21 16:15:44 UTC
README
PHP应用程序的短信组件。
安装
php composer.phar require yoqut/sms
用法
// Imports use Yoqut\Component\Sms\Factory\SmsFactory; use Yoqut\Component\Sms\Factory\GatewayFactory; use Yoqut\Component\Sms\Gateway\Matcher; use Yoqut\Component\Sms\Sender\Sender; // Create a new SMS $sms = SmsFactory::create(); $sms->setSender('Sender'); $sms->setRecipient('5550100'); $sms->setMessage('Message'); // Create a new gateway // Provide host, port, interface version, username, password, service numbers (optional), // prefix codes (optional) and configurations (optional) $gateway = GatewayFactory::create( 'localhost', 2775, 0x34 'username', 'password', array( '5555', // Production '4444' // Development ), array('555') ); // Array of gateways $gateways = array($gateway); // Create a new gateway matcher $matcher = new Matcher($gateways); $matchedGateway = $matcher->match($sms); // Print the matched gateway echo '<pre>'; print_r($matchedGateway); echo '</pre>'; if ($matchedGateway) { // Use one of the gateway service numbers as a sender if needed $serviceNumbers = $gateway->getServiceNumbers(); $sms->setSender($serviceNumbers[0]); // Send an SMS to the matched gateway $sender = new Sender(); $messageId = $sender->send($sms, $matchedGateway); echo $messageId; }
测试
bin/phpspec run
许可
作者
该组件由 Sukhrob Khakimov 创建。查看贡献者列表。