I installed Twilio sdk library using composer. After uploaded to my project and test it out, I received this error when the function is loaded.
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /home/my-codeigniter-project-domain/application/vendor/twilio/sdk/src/Twilio/Rest/Client.php on line 195
Project Environment
- CodeIgniter 3 framework
- PHP 5.6
- twilio ^6.1
My code is something like this :
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
use Twilio\Rest\Client;
class FreeSignupController extends MY_Controller
{
function __construct()
{
parent::__construct();
}
public function send_sms_demo(){
// Your Account SID and Auth Token from twilio.com/console
$sid = 'my-acc-sid';
$token = 'auth-token';
$client = new Client($sid, $token);
// Use the client to do fun stuff like send text messages!
$client->messages->create(
// the number you'd like to send the message to
'phone-number-here',
array(
'from' => 'my-twilio-phone-number',
'body' => "Hey Jenny! Good luck on the bar exam!"
)
);
}
}
In twilio Client.php error is at this line
public function request(string $method, string $uri, array $params = [], array $data = [], array $headers = [], string $username = null, string $password = null, int $timeout = null): \Twilio\Http\Response {
It's my first time using Twilio so I'm unsure what's going on.