PHP code example of room / letexto-sms-package

1. Go to this page and download the library: Download room/letexto-sms-package library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

room / letexto-sms-package example snippets


use Room\Sms\SmsClient;

$client = new SmsClient([
    'token' => 'votre_token_api',
    'base_url' => 'https://apis.letexto.com/v1'
]);

$response = $client->send([
    'to' => '2250100000000',
    'content' => 'Votre code de vérification est: 123456',
    'from' => 'MonApp'
]);

$response = $client->send([
    'to' => '2250200000000',
    'content' => 'Message de test',
    'from' => 'TestApp'
]);

$response = $client->sendBulk([
    'to' => ['2250100000000', '2250200000000'],
    'content' => 'Message en masse',
    'from' => 'MonApp'
]);



return [
    'token' => env('LETEXTO_TOKEN', ''),
    'base_url' => env('LETEXTO_BASE_URL', 'https://apis.letexto.com/v1'),
    'sender' => env('LETEXTO_SENDER', 'MonApp'),
    'timeout' => env('LETEXTO_TIMEOUT', 30),
    'logging' => env('LETEXTO_LOGGING', false),
];



namespace App\Http\Controllers;

use Room\Sms\SmsClient;

class SmsController extends Controller
{
    public function sendSms(SmsClient $smsClient)
    {
        $response = $smsClient->send([
            'to' => '2250100000000',
            'content' => 'Votre code de vérification est: 123456',
            'from' => config('letexto.sender')
        ]);

        return response()->json($response);
    }
}

public function sendSms(SmsClient $smsClient)
{
    $response = $smsClient->send([
        'to' => '2250100000000',
        'content' => 'Votre code: 123456',
        'from' => config('letexto.sender')
    ]);

    return response()->json($response);
}
bash
php artisan vendor:publish --provider="Room\Sms\SmsServiceProvider"