Download the PHP package samrap/teleapi-sms without Composer
On this page you can find all versions of the php package samrap/teleapi-sms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package teleapi-sms
Teleapi SMS
This package provides a fluent interface to the Teleapi SMS service.
Installation
Install via Composer:
composer require samrap/teleapi-sms
Usage
The Teleapi SMS package provides two classes which allow you to easily create and send text messages over HTTP.
The Client
The Client is used to send text messages to the Teleapi SMS service. The HTTP implementation is abstracted using [httplug](), allowing you to define any PSR-7 compliant client or adapter as the HTTP layer. This gives you full control over how requests are sent and allows you to easily mock API requests in unit tests.
To get started, you will need to choose the HTTP client you want to use. We recommend using the PHP HTTP CURL Client for simple applications and Guzzle for more complex apps. Of course, any PSR-7 compliant library can be used. In this example we will use the CURL Client.
First, we will add the CURL Client to our requirements:
composer require php-http/curl-client
Now that our HTTP client is installed, we can instantiate and use our SMS client:
We have now created our SMS client which is ready for use. Notice how we did not specify the HTTP client to use. Behind the scenes, the SMS client searches for any installed package that provides a php-http/client-implementation
and loads it automagically. This will only work for some clients, it is better practice to specify the HTTP client explicitly. Have a look at Clients and Adapters in the PHP HTTP documentation on how to instantiate a client. Then, simply pass it as the second argument to the SMS Client's constructor:
In any case, we are now ready to use our SMS client, so let's create a Message and send it off!
All messages are represented by the Teleapi\Sms\Message
class and are extremely simple to create:
Now, we can send the message on its way by calling the client's send
method and passing the Message as its single argument:
We can check if the message sent successfully by calling the its sent
method:
A complete example might look like the following:
More info & features coming soon!
All versions of teleapi-sms with dependencies
php-http/client-implementation Version ^1.0
php-http/httplug Version ^1.1
guzzlehttp/psr7 Version ^1.3
php-http/message Version ^1.4
php-http/discovery Version ^1.1