dexalt142 / sendtalk
Unofficial TapTalk's SendTalk library for Laravel.
Requires
- php: ^7.4||^8.0||^8.1
- guzzlehttp/guzzle: ^7.0.1
- illuminate/support: ^7|^8|^9
Requires (Dev)
- phpunit/phpunit: ^9.5.10
This package is auto-updated.
Last update: 2024-08-29 05:50:44 UTC
README
Unofficial TapTalk's SendTalk library for Laravel.
1. Installation
You can install this package through Composer CLI by running this command.
composer require dexalt142/sendtalk
Or you can modify the composer.json
file and don't forget to run composer install
.
{ "require": { "dexalt142/sendtalk": "1.*" } }
2. Configuration
Before using this package, you need to set your SendTalk API key, you can do this by adding SENDTALK_API_KEY
to the .env
file.
APP_NAME=Laravel APP_ENV=local APP_KEY= APP_DEBUG=true APP_URL=http://localhost SENDTALK_API_KEY=YOUR_SENDTALK_API_KEY_HERE ...
3. How to Use
To call all available methods, you must call it through the SendTalk Facade Dexalt142\SendTalk\Facades\SendTalk
.
3.a. Get message status
<?php namespace App\Http\Controllers; use Dexalt142\SendTalk\Facades\SendTalk; class MessageController { public function getMessage() { // SendTalk::getMessageStatus($id) $message = SendTalk::getMessageStatus('f26ccf7a-d867-b3a4-d333-117ec668718d'); } }
If the message is exists, the method above will return a result like this example below, otherwise it will throw an exception.
{ "status": "read", "isPending": false, "isSent": true, "sentTime": 1653924408488, "currency": "IDR", "price": 75, "createdTime": 1653924407993 }
3.b. Send message
<?php namespace App\Http\Controllers; use Dexalt142\SendTalk\Facades\SendTalk; class MessageController { public function sendMessage() { // SendTalk::sendTextMessage($phoneNumber, $content) $textMessage = SendTalk::sendTextMessage('+6281234567890', 'Foo Bar'); // SendTalk::sendImageMessage($phoneNumber, $imageUrl, $fileName, $caption = null) $imageMessage = SendTalk::sendImageMessage('+6281234567890', 'https://example.com/foobar.png', 'foobar.png', 'Foo Bar'); // SendTalk::sendOTPMessage($phoneNumber, $content) $otpMessage = SendTalk::sendOTPMessage('+6281234567890', 'Foo Bar'); } }
If the request was sent, the method above will return the id
of the message, otherwise it will throw an exception.