smspool / smspool-php
Official PHP client for the SMSPool API: SMS verification numbers, rentals, pre-orders and eSIMs.
Requires
- php: ^8.1
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- guzzlehttp/psr7: ^1.7 || ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- phpunit/phpunit: ^8.0 || ^9.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Official PHP client for the SMSPool API: one-time SMS verification numbers, rentals, pre-orders, eSIMs and more.
Package: smspool/smspool-php on Packagist.
Install
composer require smspool/smspool-php
Quick start
Get your API key from your settings page.
$config = SMSPool\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_API_KEY'); $info = new SMSPool\Api\InformationApi(new GuzzleHttp\Client(), $config); print_r($info->requestBalance()); $countries = $info->countryRetrieveAll(); $order = (new SMSPool\Api\SMSApi(new GuzzleHttp\Client(), $config))->purchaseSms('1', 'US');
Errors (HTTP 4xx/5xx) throw SMSPool\ApiException, with getCode() and getResponseBody().
Calling endpoints
Every endpoint in the API reference is a method named after
its path, on the class for its section: /sms/check is smsCheck() on SMSApi. Endpoints that need
your API key send it as a bearer token.
Responses are returned as decoded JSON exactly as the API sends them: many endpoints answer
200 with "success": 0 and a message when a request is refused, so check success.
- Generated reference for every method and parameter:
docs/ - API reference with examples: https://api.smspool.net/docs
How this SDK is made
The code is generated from the API's OpenAPI spec
(openapi.json) with
OpenAPI Generator. Do not edit generated files by hand:
a workflow regenerates them every week and opens a pull request when the API changed.
Hand-written files are listed in .openapi-generator-ignore.
Releasing (maintainers)
- Set the new version in
openapi-generator.yaml(artifactVersion). - Run
scripts/generate.sh(needs Docker) andscripts/smoke.sh, then commit. - Tag and push:
git tag vX.Y.Z && git push origin vX.Y.Z.
The Release workflow checks the tag against the version, runs the smoke test and publishes. There is no publish step: Packagist picks up new tags from GitHub by itself.
License
MIT