{"id":15516767,"url":"https://github.com/samrap/teleapi-sms","last_synced_at":"2025-08-05T09:12:43.208Z","repository":{"id":62539839,"uuid":"78919033","full_name":"samrap/teleapi-sms","owner":"samrap","description":"Teleapi SMS Service client implementation","archived":false,"fork":false,"pushed_at":"2017-01-14T21:46:32.000Z","size":12,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-02T21:29:11.596Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/samrap.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-14T06:06:51.000Z","updated_at":"2018-08-14T08:12:02.000Z","dependencies_parsed_at":"2022-11-02T15:46:02.946Z","dependency_job_id":null,"html_url":"https://github.com/samrap/teleapi-sms","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samrap%2Fteleapi-sms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samrap%2Fteleapi-sms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samrap%2Fteleapi-sms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samrap%2Fteleapi-sms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samrap","download_url":"https://codeload.github.com/samrap/teleapi-sms/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246088070,"owners_count":20721622,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T10:09:51.390Z","updated_at":"2025-03-28T19:29:45.677Z","avatar_url":"https://github.com/samrap.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Teleapi SMS\n\n[![Travis branch](https://img.shields.io/travis/samrap/teleapi-sms/master.svg?style=flat-square)]()\n[![StyleCI](https://styleci.io/repos/78919033/shield?branch=master)](https://styleci.io/repos/78919033)\n\nThis package provides a fluent interface to the Teleapi SMS service.\n\n### Installation\n\nInstall via Composer:\n\n`composer require samrap/teleapi-sms`\n\n### Usage\n\nThe Teleapi SMS package provides two classes which allow you to easily create and send text messages over HTTP.\n\n#### The Client\n\nThe 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](http://www.php-fig.org/psr/psr-7/) compliant client or [adapter](http://docs.php-http.org/en/latest/clients.html) 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.\n\nTo get started, you will need to choose the HTTP client you want to use. We recommend using the PHP HTTP [CURL Client](https://github.com/php-http/curl-client) for simple applications and [Guzzle](https://github.com/guzzle/guzzle) for more complex apps. Of course, any PSR-7 compliant library can be used. In this example we will use the CURL Client.\n\nFirst, we will add the CURL Client to our requirements:\n\n`composer require php-http/curl-client`\n\nNow that our HTTP client is installed, we can instantiate and use our SMS client:\n\n```php\nuse Teleapi\\Sms\\Client;\n\n$client = new Client('api_token');\n```\n\nWe 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](http://docs.php-http.org/en/latest/clients.html) 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:\n\n```php\nuse Teleapi\\Sms\\Client;\n\n// Some code to create our HTTP client...\n\n$client = new Client('api_token', $httpClient);\n```\n\nIn any case, we are now ready to use our SMS client, so let's create a Message and send it off!\n\nAll messages are represented by the `Teleapi\\Sms\\Message` class and are extremely simple to create:\n\n```php\nuse Teleapi\\Sms\\Message;\n\n$to = '7148675309';\n$from = '7141234567';\n$text = 'Welcome to our amazing product!';\n$message = new Message($to, $from, $text);\n```\n\nNow, we can send the message on its way by calling the client's `send` method and passing the Message as its single argument:\n\n```php\n$client-\u003esend($message);\n```\n\nWe can check if the message sent successfully by calling the its `sent` method:\n\n```php\n$client-\u003esend($message);\n\nif ($message-\u003esent()) {\n    echo 'Successfully sent message!';\n}\n```\n\nA complete example might look like the following:\n\n```php\nuse Teleapi\\Sms\\Client;\n\n// Some code to create our HTTP client...\n\n$client = new Client('api_token', $httpClient);\n$message = new Message(\n    '7148675309',\n    '7141234567',\n    'Welcome to our amazing product!'\n);\n\n$client-\u003esend($message);\n\nif ($message-\u003esent()) {\n    echo 'Successfully sent message!';\n}\n```\n\n## More info \u0026 features coming soon!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamrap%2Fteleapi-sms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamrap%2Fteleapi-sms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamrap%2Fteleapi-sms/lists"}