PHP code example of padosoft / laravel-rebel-channel-vonage
1. Go to this page and download the library: Download padosoft/laravel-rebel-channel-vonage 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/ */
padosoft / laravel-rebel-channel-vonage example snippets
use Padosoft\Rebel\Channels\Enums\Channel;
use Padosoft\Rebel\Channels\Routing\VerificationRouter;
use Padosoft\Rebel\Core\Context\SecurityContext;
use Padosoft\Rebel\Core\Contracts\KeyedHasher;
use Padosoft\Rebel\Core\Identifiers\PhoneIdentifier;
$router = app(VerificationRouter::class);
$ctx = SecurityContext::fromRequest($request, app(KeyedHasher::class));
// Send a code (Vonage Verify delivers it)
$start = $router->start(PhoneIdentifier::from('+39 333 1234567'), Channel::Sms, $ctx);
// Keep $start->reference (the Vonage request_id) — you pass it back on check.
$reference = $start->reference;
// Check what the user typed
$result = $router->check(PhoneIdentifier::from('+39 333 1234567'), $request->string('code'), $reference, $ctx);
if ($result->approved()) {
// verified!
}
use Padosoft\Rebel\Channels\Contracts\MessageDeliveryChannel;
use Padosoft\Rebel\Channels\Enums\Channel;
use Padosoft\Rebel\Channels\Routing\ProviderRegistry;
$vonage = app(ProviderRegistry::class)->get('vonage');
if ($vonage instanceof MessageDeliveryChannel) {
$result = $vonage->send(
PhoneIdentifier::from('+39 333 1234567'),
'Your order has shipped!',
Channel::Sms,
$ctx,
);
$result->accepted(); // true when Vonage accepted it for delivery
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.