Download the PHP package prinx/txtconnect without Composer
On this page you can find all versions of the php package prinx/txtconnect. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package txtconnect
TXTCONNECT PHP SDK
TXTCONNECT is a platform that allows you to send SMS and voice messages to your specified contact list.
This package provides a convenient way of interacting with TXTCONNECT's API. It allows you to send SMS, check your SMS status, get your SMS inbox, check your account balance, without worrying about direct API calls.
Then you are ready to go.
Installation
Usage
Configuration
Create a .env
file at the root of your project (where the vendor folder is located), if none exists already.
In the .env
file specify your TxtConnect API credentials:
Sending SMS
Specifying the HTTP method
Number formats
The number is automatically sanitized, any space, parenthesis, hyphen, is removed. This allows to pass the number without worrying about the correct format.
For example:
- +233 24 24 24 242
- 233(0)24 24 24 242
- 233 24 24-24-242
- etc
The only constraint is the number has to be in an international format. This constraint can be ignored by specifying a default country.
Specifying the default country
Specifying a default country allows to send SMS without worrying if the number is in international format or not. The package will automatically resolve and put the number in required format. For example, after specifying the default country as Ghana
, you can send SMS to the number like 020 00 00 000, without putting it in international format.
Sending SMS to more than one number
You can send SMS to many numbers at once just by adding the numbers as an array to the send
method:
Using the to
method
The phone numbers can be passed to the sms instance ahead of time, before calling the send
method:
And for more numbers:
or
or
Handling duplicate
By default, the package handles automatically duplicate numbers and does not send sms to duplicate numbers (unless it is explicitly activated).
Sending to duplicate
If you wish to send sms to duplicate numbers, you can activate it by calling the keepDuplicate
method on the sms instance.
Deactivate sending to duplicate
If you wish to send sms to duplicate numbers, you can activate it by calling the removeDuplicate
method on the sms instance.
Invalid numbers
Sms will not be forwarded to invalid numbers.
Invalid numbers are:
- a number for which the package is not able to determine the country;
- a number that is not a phone number;
- a number that cannot receive an sms (a fixed phone number, for example).
This allows you not to waste bandwidth to make HTTP request to numbers that will not get the message you are sending and at the same time allows not to waste you TXTCONNECT balance.
SMS response
After sending an SMS, the response let you know if the SMS has been received by TXTCONNECT or if an error happened.
Single SMS response
When sending an SMS to only one contact, the send
method will return an SmsResponse
instance:
Multiple SMS response (SmsResponseBag)
When sending SMS to multiple contacts, the send
method will return an SmsResponseBag
containing the SmsResponse
of every contact:
The first and last response can be accessed using the first
and last
method:
Forcing SmsResponseBag
You can force the send
method to always return a SmsResponseBag
weither the SMS has been sent to only one number or multiple numbers by calling the asBag
method on the sms instance:
Get SMS status
Get Status of many SMS at a go
Adding batch number one by one
Batch numbers can be added one by one instead of passing all as an array to the of
method:
Fluent interface
The SmsStatus
class implement a fluent interface, so the of
method can be chained:
Using first
and last
The SmsStatus
class also extends the SmsBagAbstract, so when retrieveing statuses of more than one batch numbers, the first and last elements can be retrieved using the first
and last
method:
All the statuses fetched
Count number of statuses fetched
Get Balance
Get SMS Inbox
Contributing
- Give a :star: to the repo, it's free :grin:
- Fork the repo;
- correct a bug, add a feature;
- and create a pull request.
License
MIT
All versions of txtconnect with dependencies
symfony/http-client Version ^6.1
league/iso3166 Version ^4.1
prinx/notify Version ^0.1
prinx/slack-log Version ^2.0
prinx/dotenv Version ^1.0