繁体   English   中英

使用twilio错误时无法发送短信

[英]Can't send sms using twilio error occured

我试图在twilio API的帮助下使用php发送短信。 但是我在运行代码时遇到了一些错误。

我的代码

{require ('./twilio/Services/Twilio.php'); // Loads the library


$accountSid = 'AC****************************';
$authToken  = 'ec****************************'; 
$client = new Services_Twilio($accountSid, $authToken);

$sms = $client->account->sms_messages->create("number", "number", "Jenny please?! I love you <3");

错误

警告:file_get_contents():SSL操作失败,代码为1. OpenSSL错误消息:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证在C:\\ wamp \\ www \\ Pizza4U \\ twilio \\ Services \\ Twilio \\ HttpStream.php中失败62

警告:file_get_contents():无法在第62行的C:\\ wamp \\ www \\ Pizza4U \\ twilio \\ Services \\ Twilio \\ HttpStream.php中启用加密

有没有办法解决这个问题。 谢谢

要在测试时避免wampserver localhost上的SSL证书问题,请确保插入以下代码行:

CURLOPT_SSL_VERIFYPEER => false,

twilio / sdk / Twilio / Http / CurlClient.php(从第113行开始)

public function options($method, $url, $params = array(), $data = array(),
                        $headers = array(), $user = null, $password = null,
                        $timeout = null) {

    $timeout = is_null($timeout)
        ? self::DEFAULT_TIMEOUT
        : $timeout;
    $options = $this->curlOptions + array(
        CURLOPT_URL => $url,
        CURLOPT_HEADER => true,
        CURLOPT_RETURNTRANSFER => true,
        //added here during localhost wampserver testing to avoid SSL issues
        //CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_INFILESIZE => Null,
        CURLOPT_HTTPHEADER => array(),
        CURLOPT_TIMEOUT => $timeout,
    );

在生产模式下删除该行。 您托管的服务器我肯定会拥有正确的可信证书包。 至少将此设置设置为false,localhost上的twilio应用程序将不会检查您的localhost是否有SSL证书。 这样可以避免必须下载正确的证书并完全绕过问题。 请参阅https://github.com/twilio/twilio-php/issues/203上的 pflammer的评论。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM