【发布时间】:2017-09-20 08:21:34
【问题描述】:
<?php
class SmsSenderManager{
function sendSms($from,$to,$accountId,$token,$msg){
$strFromNumber = $from;
$strToNumber = $to;
$strMsg = $msg;
$result = new stdClass();
require_once ("Services/Twilio.php");
$AccountSid = $accountId;
$AuthToken = $token;
$objConnection = new Services_Twilio($AccountSid, $AuthToken);
$bSuccess = $objConnection->account->sms_messages->create(
$strFromNumber,
$strToNumber,
$strMsg
);
$result->content = $strMsg;
$result->success = true;
return $result;
}
}
?>
上面的代码可以完美发送 SMS,但在 Windows 服务器上的 IIS 服务器上部署时无法在实时项目上运行。我见过很少有与这个问题相关的帖子,但大多数人都建议在服务器上允许 curl。如果是,请告诉如何在 IIS 服务器上启用 curl
【问题讨论】:
-
谷歌“启用 curl IIS”
-
当你喋喋不休的时候,为什么不花时间在这里输入一个有效的代码段呢?这个肯定不在本地主机上“工作”。
-
其实twillio php sms api包含很多文件。文档可以在github.com/twilio/twilio-php看到
-
已解决!实际上问题出在 IIS 服务器上的 SSL 证书中。只需在 twilio lib 中打开 TinyHttp.php:在 $opts 数组中添加 CURLOPT_SSL_VERIFYPEER => FALSE
标签: php sms twilio-php