0

I am quite a beginner in PHP so my apologies.

I have spent many hours googling now and i still keep getting the same errors, I am trying to get a sms service up at running using twilio. I have installed composer, ran the 'composer require twilio/sdk' script. Below is the starter code which should allow you to send messages. Also running server with WAMP.

"( ! ) Parse error: syntax error, unexpected 'use' (T_USE) in C:\wamp64\www\send-message.php on line 3" is the error all the time

Sorry to ask, I just really confused on the reasoning.

<?php
 require __DIR__ . '/vendor/autoload.php'
 use Twilio\Rest\Client;
 $sid = 'whereSIDwouldgo'; // have checkd this
 $token = 'whereTokenWouldgo'; // have checked this
 $client = new Client($sid, $token);
 $client->messages->create(
       '+440000000000',// normally have registered number
   array(
    // A Twilio phone number you purchased at twilio.com/console
    'from' => '+4400000000',// normally have registered number
    // the body of the text message you'd like to send
    'body' => 'Hey, hows it going?'
)
);
?>
funnypeople
  • 17
  • 1
  • 7
  • "( ! ) Parse error: syntax error, unexpected 'use' (T_USE) in C:\wamp64\www\send-message.php on line 3" is the error all the time – funnypeople Jul 04 '18 at 11:02
  • You're missing the end statement `;` on the first line, it should be `require __DIR__ . '/vendor/autoload.php';` Personally I put brackets around my includes / requires as I help it reminds me to put the semi colon `require("whatever.php");` its so habitual for me these days. Also you may want to look into a decent IDE with code completion.. it would have spotted this for you – Dale Jul 04 '18 at 11:07
  • Thanks so much for the reply. I did that but now a worse error, Fatal error: Uncaught exception 'Twilio\Exceptions\EnvironmentException' with message 'Could not resolve host: api.twilio.com' in C:\wamp64\www\vendor\twilio\sdk\Twilio\Http\CurlClient.php on line 41 ( ! ) Twilio\Exceptions\EnvironmentException: Could not resolve host: api.twilio.com in C:\wamp64\www\vendor\twilio\sdk\Twilio\Http\CurlClient.php on line 41 – funnypeople Jul 04 '18 at 11:29
  • I haven't used twilio for a long, time, does it require ssl? have you got ssl enabled in php? it could be a few different things – Dale Jul 04 '18 at 11:33
  • Sorted it now, just had to enable php_openssl and enter the cacert path :). Thanks though – funnypeople Jul 04 '18 at 12:24

0 Answers0