John Davidson

php - Twilio: SSL certificate problem: unable to get local issuer certificate

0 comments
Message:


I am trying to send SMS using Twilio in PHP using the sample code included on their site as seen in the documentation here


This is the full description of the error I am getting when I try run the PHP file with the Twilio code:


Fatal error: Uncaught Twilio\Exceptions\EnvironmentException: SSL certificate problem: unable to get local issuer certificate in C:\wamp\www\uniSoftX\vendor\twilio\sdk\src\Twilio\Http\CurlClient.php on line 40

Twilio\Exceptions\EnvironmentException: SSL certificate problem: unable to get local issuer certificate in C:\wamp\www\uniSoftX\vendor\twilio\sdk\src\Twilio\Http\CurlClient.php on line 40

After researcch I came across an article from Twilio saying this issue can be caused by Twilio changing their root certificate to DigiCert Global Root CA. I installed that root certificate and still no luck.


I'm on windows with PHP 7.24 running WAMP server.


This is my code:


<?php


require_once "../vendor/autoload.php";

use Twilio\Rest\Client;

$sid = "0000000000000000000000000";
$token = "000000000000000000000000";
$twilio = new Client($sid, $token);

$message = $twilio->messages
->create("+0000000000", // to
[
"body" => "This is the ship that made the Kessel Run in fourteen parsecs?",
"from" => "+0000000000",
"mediaUrl" => ["https://c1.staticflickr.com/3/2899/14341091933_1e92e62d12_b.jpg"]
]
);

print($message->sid);
?>


My Answer:
php

require_once 'vendor/autoload.php';

use Twilio\Rest\Client;

// Your Account SID and Auth Token from twilio.com/console
$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = 'your_auth_token';

// A Twilio number you own with SMS capabilities
$twilio_number = "+15017122661";

$client = new Client($account_sid, $auth_token);

$client->messages->create(
// Where to send a text message (your cell phone?)
'+15558675310',
array(
'from' => $twilio_number,
'body' => 'Hello from Twilio!'
)
);


Make sure to replace `'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'` with your actual Account SID and `'your_auth_token'` with your actual Auth Token. Also, replace `'+15017122661'` with your Twilio number and `'+15558675310'` with the number you want to send the SMS to.

If you have already installed the DigiCert Global Root CA certificate and are still facing the issue, you may need to check your PHP configuration to ensure that the certificate is being recognized. You can also try updating your PHP version or checking for any other SSL-related configuration issues on your server.

Rate this post

5 of 5 based on 8845 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us