PHP code example of ibrahem-kamal / omni-messaging
1. Go to this page and download the library: Download ibrahem-kamal/omni-messaging 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/ */
ibrahem-kamal / omni-messaging example snippets
return [
/**
* Channels should be added in the following format:
* 'channels' => [
* 'channel_name' => [
* 'driver' => 'driver_name',
* 'options' => []
* ]
* ]
*/
'channels' => [],
'webhook' => [
'queue' => 'default',
],
];
$sms = OmniMessaging::driver('jawaly')->send($message,$mobileNumber,$sender,$options = []);
$sms->isSuccess(); //bool
$sms->getErrorsString(); // errors as string
$sms->getErrors(); // errors as array
$sms->getData(); // array of data returned from the gateway
$sms->toArray(); // array of all the above
$balance = OmniMessaging::driver('jawaly')->getBalance();
$balance->isSuccess(); //bool
$balance->getErrorsString(); // errors as string
$balance->getErrors(); // errors as array
$balance->getData(); // array of data returned from the gateway
$balance->toArray(); // array of all the above
// in your event service provider
OmniMessagingWebhookUpdateEvent::class => [
YourListener::class,
]
public function handle(OmniMessagingWebhookUpdateEvent $event)
{
foreach ($event->parsedWebhookData as $parsedNumber) {
$parsedNumber->getNumber(); // phone number string
$parsedNumber->getFrom(); // sender string
$parsedNumber->getReference(); // reference string such as message id
$parsedNumber->isSuccess(); // bool
$parsedNumber->getError(); // string
$parsedNumber->toArray(); // array of all the above
}
}