jbbx2016 / sms-gateway
SMS Gateway to interface with Eurobate
Installs: 6 118
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- php: ^5.4 | ^7.0
- ext-iconv: *
- giggsey/libphonenumber-for-php: ^8.3.3
- guzzlehttp/guzzle: ^6.0
- twilio/sdk: ^5.9
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