我将尝试使用Twilio提供的示例代码在PHP中发送短信,具体参考他们网站文档 此处。但是,在运行带有Twilio代码的PHP文件时,我遇到以下完整错误描述:
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
在研究后,我发现了一篇来自Twilio的文章,说这个问题可能是由于Twilio将其根证书更改为DigiCert Global Root CA所致。我安装了该根证书,但仍然没有成功。
我使用运行WAMP服务器的Windows和PHP 7.24。
这是我的代码:
<?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);
?>