PHP code example of vonage / vonage-laravel

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

    

vonage / vonage-laravel example snippets


$text = new \Vonage\SMS\Message\SMS($toNumber, $fromNumber, 'Test SMS using Laravel');
Vonage::sms()->send($text);

$vonage = app('Vonage\Client');
$text = new \Vonage\SMS\Message\SMS($toNumber, $fromNumber, 'Test SMS using Laravel');
$vonage->sms()->send($text);

$outboundCall = new \Vonage\Voice\OutboundCall(
    new \Vonage\Voice\Endpoint\Phone('14843331234'),
    new \Vonage\Voice\Endpoint\Phone('14843335555')
);
$outboundCall
    ->setAnswerWebhook(
        new \Vonage\Voice\Webhook('https://example.com/answer')
    )
    ->setEventWebhook(
        new \Vonage\Voice\Webhook('https://example.com/event')
    )
;

$response = Vonage::voice()->createOutboundCall($outboundCall);
bash
php artisan vendor:publish --provider="Vonage\Laravel\VonageServiceProvider"