1. Go to this page and download the library: Download j42/laravel-twilio 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/ */
use J42\LaravelTwilio\TwilioVerify;
class TwilioController extends TwilioVerify {
// Verify Phone
public function verify() {
// Your pre-verification logic
// Magic
// You can rmation token.
$response = parent::verify($message);
// Your post-verification logic
// $this->phone === Cookie::get('twilio::phone') === json_decode($response)['data']
return $response;
}
}
Twilio::sms([
// From (optional -- if unsupplied, will be taken from default Config::get('twilio::config.from'))
'from' => '<your twilio #>'
// Array of recipients
'to' => ['19999999999'],
// Text Message
'message' => 'Contents of the text message go here'
]);
Twilio::call([
// From (optional -- if unsupplied, will be taken from default Config::get('laravel-twilio::from'))
'from' => '<your twilio #>'
// Array of recipients
'to' => ['19999999999'],
// Relative path to twiml document/endpoint (combined with Config::get('laravel-twilio::twiml') to form an absolute URL endpoint)
// You could also specify an abslute URL (http:// or https:// which would not be modified)
'twiml' => 'twilio/verify/twiml'
]);
// Response Statuses:
// QUEUED, RINGING, IN-PROGRESS, COMPLETED, FAILED, BUSY or NO_ANSWER.
// Near Area Code (With MMS Capability) + Buy 2
Twilio::numbersNear([ 'AreaCode' => '415' ], ['MmsEnabled' => true], 2);
// Near Another Phone #
Twilio::numbersNear([
'NearNumber' => '415XXXXXX', // Other Number
'Distance' => '50' // Miles (optional, default: 25)
]);
// Near A City (any combination allowed)
Twilio::numbersNear([
'InRegion' => 'CA', // State/Region/Province Code
'InPostalCode' => '90017' // Postal code?
]);
// Near Lat/Long Coordinates
Twilio::numbersNear([
'NearLatLong' => '37.840699,-122.461853',
'Distance' => '50'
]);
// ... you get the idea. Most fields can be mixed and matched arbitrarily, but if you are wondering, test it out for yourself!
// By Regex
// Valid characters are '*' and [0-9a-zA-Z]. The '*' character will match any single digit.
Twilio::numbersNear([ 'Contains' => 'J42' ]); // Matches String
Twilio::numbersNear([ 'Contains' => '510555****' ]); // Matches Pattern
// Purchase Phone Numbers
Twilio::buyNumber('4151111111'); // Valid as a single request
Twilio::buyNumber([
'4151111111',
'4152222222'
]); // Or an array
// Including a configuration is recommended, but optional
Twilio::buyNumber([
'4151111111',
'4152222222'
], [
'VoiceUrl' => 'myendpoint',
'SmsUrl' => 'mysmsendpoint',
'VoiceMethod' => 'GET'
]);
// Associate a # with a new TWIML endpoint
Twilio::update(Twilio::buyNumber('4151111111'), [
'VoiceUrl' => '<new twiml endpoint>'
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.