PHP code example of boyo / laravel-sinch

1. Go to this page and download the library: Download boyo/laravel-sinch 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/ */

    

boyo / laravel-sinch example snippets


'sinch' => [
	'api_key' => env('SINCH_API_KEY',''),
	'service_plan_id' => env('SINCH_PLAN_ID',''),
	'from' => env('SINCH_FROM',''),
	'prefix' => '',
	'log' => env('SINCH_LOG',true),
	'log_channel' => env('SINCH_LOG_CHANNEL','stack'),
	'send' => env('SINCH_SEND',false),
	'bulglish' => true,
	'allow_multiple' => false,
],

use Boyo\Sinch\SinchMessage;
use Boyo\Sinch\SinchSender;

class MyClass
{
	public function myFunction()
	{
		$message = (new SinchMessage())->to('359888888888')->channel('sms')->sms('SMS text');
		
		$client = new SinchSender();
		$client->send($message);	
	}
}

use Boyo\Sinch\SinchMessage;

class MyMessage extends SinchMessage 
{
	public function __construct($data)
    {
        $this->id = $data->id; // your unique message id, add other parameters if needed
    }
    
	public function build() {
		// set your sms text 
		$this->sms('SMS text');
		
		return $this;
	}	
}

use Boyo\Sinch\SinchChannel;

via($notifiable) 
{
	
	// ...
	
	$via[] = SinchChannel::class;
	
	return $via 
	
}

public function toSms($notifiable)
{
	return (new MyMessage($unique_id))->to($notifiable->phone)->channel('sms');
}