The documentation for the GREENSMS API can be found here.
composer require greensms/greensms
Check out these code examples to get up and running quickly.
use GreenSMS\GreenSMS;
# Register at my.greeensms.ru first
$client = new GreenSMS([
'user' => 'test',
'pass' => 'test'
]);
$response = $client->sms->send([
'to' => '79260000121',
'txt' => 'Here is your message for delivery'
]);
echo "Sms Request Id: " . $response->request_id;
greensms-php
supports credential storage in environment variables. If no credentials are provided following env vars will be used: GREENSMS_USER
/GREENSMS_PASS
OR GREENSMS_TOKEN
.
use GreenSMS\GreenSMS;
$tokenClient = new GreenSMS([
'token' => 'yourtoken'
]);
$response = $tokenClient->account->balance();
echo "Balance : " . $response->balance. "\n";
greensms-php
is compatible with PHP 7.3+ onwards until the latest PHP Version
- You can either use username/password combination or auth token to create an object with constructor
- Each API Function is available as
MODULE.FUNCTION()
- Parameters for each API can be referred from here
- Response keys by default are available in
snake_case
. If you want to usecamelCase
, then pass'camelCaseResponse'= > true
, in the constructor
- Exceptions for all APIs are thrown with RestException class. It extends the default PHP Exception class.
- Each error, will have a message and code similar to PHP Exceptions.
- In case of Validation Error, additional params are available to show field-wise rule failures. Can be accessed by
$e->getParams()
method on the error object
If you need help installing or using the library, please contact us: [email protected].
If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!
Bug fixes, docs, and library improvements are always welcome. Please refer to our Contributing Guide for detailed information on how you can contribute. If you're not familiar with the GitHub pull request/contribution process, this is a nice tutorial.
If you want to familiarize yourself with the project, you can start by forking the repository and cloning it in your local development environment. The project requires Node.js to be installed on your machine.
After cloning the repository, install the dependencies by running the following command in the directory of your cloned repository:
composer require
GreenSMS has all the unit tests defined under tests folder with *Test.php
extension. It uses PHPUnit, which is added as a dev dependency. You can run all the tests using the following command.
./vendor/bin/phpunit tests