PHP code example of boyo / mobica

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


'mobica' => [
	'user' => env('MOBICA_USER',''),
	'pass' => env('MOBICA_PASS',''),
	'prefix' => '',
	'log' => env('MOBICA_LOG',true),
	'log_channel' => env('MOBICA_LOG_CHANNEL','stack'),
	'send' => env('MOBICA_SEND',false),
	'bulglish' => true,
	'allow_multiple' => false,
],

use Boyo\Mobica\MobicaMessage;
use Boyo\Mobica\MobicaSender;

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

use Boyo\Mobica\MobicaMessage;

class MyMessage extends MobicaMessage 
{
	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\Mobica\MobicaChannel;

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

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