PHP code example of boyo / laravel-link-mobility

1. Go to this page and download the library: Download boyo/laravel-link-mobility 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-link-mobility example snippets


'link-mobility' => [
	'api_key' => env('LINK_MOBILITY_API_KEY',''),
	'api_secret' => env('LINK_MOBILITY_API_SECRET',''),
	'service_id' => env('LINK_MOBILITY_SERVICE_ID', '1'),
	'sc_sms' => env('LINK_MOBILITY_SMS_SENDER', ''),
	'sc_viber' => env('LINK_MOBILITY_VIBER_SENDER', ''),
	'prefix' => '',
	'log' => env('LINK_MOBILITY_LOG',true),
	'log_channel' => env('LINK_MOBILITY_LOG_CHANNEL','stack'),
	'send' => env('LINK_MOBILITY_SEND',false),
	'bulglish' => true,
	'allow_multiple' => false,
],

use Boyo\LinkMobility\LinkMobilityMessage;
use Boyo\LinkMobility\LinkMobilitySender;

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

use Boyo\LinkMobility\LinkMobilityMessage;

class MyMessage extends LinkMobilityMessage 
{
	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');
	
		// set your viber text
		$this->viber('Viber text');
		
		return $this;
	}	
}

use Boyo\LinkMobility\LinkMobilityChannel;

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

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