I've got the following php file below. When I run it from the terminal, it works great. However, when I open php file in the browser, I get the following exception:
Fatal error: Uncaught exception 'Twilio\Exceptions\EnvironmentException' with message 'SSL certificate problem: unable to get local issuer certificate' in /Applications/AMPPS/www/vendor/twilio/sdk/Twilio/Http/CurlClient.php:41 Stack trace: #0 /Applications/AMPPS/www/vendor/twilio/sdk/Twilio/Rest/Client.php(208): Twilio\Http\CurlClient->request('POST', 'https://api.twi...', Array, Array, Array, 'AC9fc89840f15b3...', 'd1db324eb375a2e...', NULL) #1 /Applications/AMPPS/www/vendor/twilio/sdk/Twilio/Domain.php(70): Twilio\Rest\Client->request('POST', 'https://api.twi...', Array, Array, Array, NULL, NULL, NULL) #2 /Applications/AMPPS/www/vendor/twilio/sdk/Twilio/Version.php(64): Twilio\Domain->request('POST', '2010-04-01/Acco...', Array, Array, Array, NULL, NULL, NULL) #3 /Applications/AMPPS/www/vendor/twilio/sdk/Twilio/Version.php(216): Twilio\Version->request('POST', '/Accounts/AC9fc...', Array, Array, Array, NULL, NULL, NULL) #4 /Applications/AMPPS/www/vendor/twilio/sdk/Twilio/Rest/Api/V2010/Account/MessageList.php(70): Twili in /Applications/AMPPS/www/vendor/twilio/sdk/Twilio/Http/CurlClient.php on line 41
Here is my code:
<?php // sendMessageTwilio.php
require __DIR__ . '/vendor/autoload.php';
use Twilio\Rest\Client;
// Your Account SID and Auth Token from twilio.com/console
$account_sid = 'XXXXXXXXXX';
$auth_token = 'XXXXXXXXXX';
// In production, these should be environment variables. E.g.:
// $auth_token = $_ENV["TWILIO_ACCOUNT_SID"]
// A Twilio number you own with SMS capabilities
$twilio_number = "+XXXXXXXX";
$client = new Client($account_sid, $auth_token);
$client->messages->create(
// Where to send a text message (your cell phone?)
'+XXXXXXXXXXX',
array(
'from' => $twilio_number,
'body' => 'Testing From Website New!'
)
);
$number = $question = '';
if (isset($_POST['number'])){
$number = $_POST['number'];
$out = "Number: $number";
}
if (isset($_POST['question'])){
$question = $_POST['question'];
$out = $out." Question: $question";
}
else $out = "";
echo <<<_END
<html>
<head>
<title>Student Feedback</title>
</head>
<body>
<pre>
Enter phone number and question
<b>$out</b>
<form method="post" action="sendMessageTwilio.php">
Phone Number: <input type="text" name="number" size="17">
Question: <input type="text" name="question" size="17">
<input type="submit" value="Send Message">
</form>
</pre>
</body>
</html>
_END;
I'm using the composer to get all the necessary files set up.
Thanks all!