touchsms / touchsms
touchSMS Api Client
2.0.0
2024-02-10 16:00 UTC
Requires
- php: >=8.0
- jane-php/open-api-runtime: ~7.6.0
- php-http/client-common: ^1.9 || ^2.0
- php-http/discovery: ^1.11
- php-http/multipart-stream-builder: ^1.1
- psr/http-client-implementation: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.2.2
- jane-php/open-api-3: ~v7.6.0
- nyholm/psr7: ^1.2
- opis/json-schema: ^1.0
- symfony/console: ^6.0 || ^7.0
- symfony/http-client: ^6.0 || ^7.0
- symfony/phpunit-bridge: ^6.0 || ^7.0
- symfony/process: ^6.0 || ^7.0
Conflicts
- php-http/httplug: < 2.0
This package is not auto-updated.
Last update: 2025-01-18 18:47:53 UTC
README
PHP SDK for touchSMS.
This SDK is generated automatically with JanePHP. It provides a full object-oriented interface for the endpoints, requests and responses.
You can explore the \TouchSms\ApiClient\Api
namespace to see the generated classes.
Currently, only a portion of the API has been converted to openAPI, and thus this client. If you would like support for a method, please open an issue and our team will address it.
Installation
composer require touchsms/touchsms
Usage
Use the ClientFactory
to create an API client.
// access token & token id can be generated at https://app.touchsms.com.au/settings/api $client = \TouchSms\ApiClient\ClientFactory::create('ACCESS_TOKEN', 'TOKEN_ID'); $res = $client->getAccount();
Send SMS
$client = ClientFactory::create($_ENV['ACCESS_TOKEN'], $_ENV['TOKEN_ID']); $res = $client->sendMessages(new SendMessageBody([ 'messages' => [ // Up to 1000 messages supported new OutboundMessage([ 'to' => '61491578888', // Test number 'from' => 'SHARED_NUMBER', 'body' => 'Text', ]), ], ])); var_dump($res->getData()->getMessages()); // Successful messages, \TouchSms\ApiClient\Api\Model\OutboundMessageResponse var_dump($res->getData()->getErrors()); // Messages with errors, \TouchSms\ApiClient\Api\Model\OutboundMessageError
Output
// array of OutboundMessageResponse objects $message = $res->getData()->getMessages()[0]; $message->getTo(); $message->getMeta()->getParts(); $message->getMeta()->getCost(); //etc
View User Details
$res = $client->getAccount();
Output
var_dump($res->getData()); // object, \TouchSms\ApiClient\Api\Model\AccountInformation var_dump( $res->getData()->getEmail(), // user $res->getData()->getCredits() // credit balance );
Examples
Examples can be found in examples
directory.