katsana / silverstreet
Silverstreet API Client for PHP
Installs: 16 155
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 6
Forks: 3
Open Issues: 0
Requires
- php: ^7.2 || ^8.0
- laravie/codex: ^5.1
- php-http/multipart-stream-builder: ^1.0
Requires (Dev)
- illuminate/notifications: ^5.8 || ^6.0 || ^7.0 || ^8.0
- illuminate/support: ^5.8 || ^6.0 || ^7.0 || ^8.0
- laravie/parser: ^2.0
- mockery/mockery: ^1.3
- php-http/guzzle7-adapter: ^0.1.1
- phpunit/phpunit: ^7.5 || ^8.4 || ^9.0
Suggests
- laravie/parser: Allows to use credit balance checker (^2.0).
README
Installation
To install through composer, simply put the following in your composer.json
file:
{ "require": { "katsana/silverstreet": "^3.0", "php-http/guzzle6-adapter": "^2.0" } }
HTTP Adapter
Instead of utilizing php-http/guzzle6-adapter
you might want to use any other adapter that implements php-http/client-implementation
. Check Clients & Adapters for PHP-HTTP.
Usages
Creating Silverstreet Client
You can start by creating a client by using the following code (which uses php-http/guzzle6-adapter
):
<?php use Silverstreet\Client; $http = Laravie\Codex\Discovery::client(); $silverstreet = new Client($http, 'your-api-username', 'your-api-password');
You could also use php-http/discovery
to automatically pick available adapter installed via composer:
<?php use Silverstreet\Client; $silverstreet = Client::make('your-api-username', 'your-api-password');
Sending Text Messages
You can send text messages by running the following code.
$silverstreet->uses('Message') ->text('Hello world', '+60123456789', $sender);
Checking Credit Balance
You can request for available balance by running the following code.
$balance = $silverstreet->uses('Credit')->available(); echo $balance; // 400