I have the below code (ON AFTER INSERT/UPDATE EVENTS) which is supposed to send an sms using the Twilio REST API. However the code is throwing an error where
I have the
Use Twilio\Rest\Client
line saying
Parse error: syntax error, unexpected ‘use’ (T_USE) in …\scriptcase\app ests\send_sms\send_sms_apl.php on line 1973
I will be happy if somebody can point me in the right direction on how to call this API from an external library.
require_once ‘…/Twilio/Twilio/autoload.php’;
// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;
// Your Account SID and Auth Token from twilio.com/console
$sid = ‘’;
$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
‘Recieving_Number’,
array(
// A Twilio phone number you purchased at twilio.com/console
‘from’ => ‘Sending_Number’,
// the body of the text message you’d like to send
‘body’ => “sms sent from php!”
)
);
Thanks.