jbbx2016/sms-gateway
Composer 安装命令:
composer require jbbx2016/sms-gateway
包简介
SMS Gateway to interface with Eurobate
README 文档
README
Library to send SMS using Eurobate gateway
Installation using Composer
composer require jbbx2016/sms-gateway
Basic usage
<?php
use JBBx2016\SMSGateway\Common\CountryCodes;
use JBBx2016\SMSGateway\Common\Exceptions\Exception;
use JBBx2016\SMSGateway\Common\PhoneNumber;
use JBBx2016\SMSGateway\Gateways\Eurobate\EurobateSendMessageResponse;
use JBBx2016\SMSGateway\Gateways\Eurobate\EurobateGateway;
use JBBx2016\SMSGateway\Payloads\SMSPayload;
use JBBx2016\SMSGateway\Senders\TextSender;
use JBBx2016\SMSGateway\SMSGatewayApi;
$SMSGatewayApi = new SMSGatewayApi();
$SMSGatewayApi->AddGateway(new EurobateGateway('username', 'password'));
try {
/** @var EurobateSendMessageResponse $Response */
$Response = $SMSGatewayApi->SendMessage(
new TextSender('Avsender'),
new SMSPayload(
new PhoneNumber(CountryCodes::Norway, '98765432'),
"This is the message body"
)
);
$EurobateId = $Response->Id;
} catch (Exception $Exception) {
$this->_Logger->Error('Failed to process SMS - Exception: ' . get_class($Exception) . "(" . $Exception->getMessage() . ")");
}
Send SMS from number
<?php
use JBBx2016\SMSGateway\Common\CountryCodes;
use JBBx2016\SMSGateway\Common\PhoneNumber;
use JBBx2016\SMSGateway\Payloads\SMSPayload;
use JBBx2016\SMSGateway\Senders\NumberSender;
$SMSGatewayApi->SendMessage(
new NumberSender('203098765432'),
new SMSPayload(
new PhoneNumber(CountryCodes::Norway, '98765432'),
"This is the message body"
)
);
Eurobate: Specify delivery report endpoint
<?php
use JBBx2016\SMSGateway\Gateways\Eurobate\EurobateGateway;
use JBBx2016\SMSGateway\SMSGatewayApi;
$EurobateGateway = new EurobateGateway('username', 'password');
$EurobateGateway->SetDeliveryReportStatusEndpoint('http:// myhost.com/dlr.php?msgid=MSGID&status=STATUS&operator=OPERATOR&smscode=OPCODE&cbgcode=CBGCODE&stop=STOP');
$SMSGatewayApi = new SMSGatewayApi();
$SMSGatewayApi->AddGateway($EurobateGateway);
Exceptions
JBBx2016\SMSGateway\Common\Exceptions\Exception: Base exceptionJBBx2016\SMSGateway\Common\Exceptions\GatewayEndpointConnectionFailedException: Connection to gateway endpoint failedJBBx2016\SMSGateway\Common\Exceptions\GatewayAuthorizationException: Gateway authorization failedJBBx2016\SMSGateway\Common\Exceptions\NoGatewayFoundException: Called if no appropriate gateway is foundJBBx2016\SMSGateway\Gateways\Eurobate\EurobateException: Exception for Eurobate gatewayJBBx2016\SMSGateway\Gateways\Eurobate\Exceptions\IPNotAuthorizedEurobateException: Eurobate specific error
统计信息
- 总下载量: 6.19k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2017-02-21