'octOap8wLMsXIS38', 'secret' => 'rqjJg3Hg4jiGsWH4C5wCVzegZUKxHgRU', 'signName' => '【猎豆优选】', 'templateId' => 'SMS_151992296' ); // 配置参数 $this->accesskey = $cofig ['accesskey']; $this->secret = $cofig ['secret']; $this->signName = $cofig ['signName']; $this->templateId = $cofig ['templateId']; } /** * @param unknown $mobile * @param unknown $verify_code * */ public function send_verify($mobile, $verify_code, $minute) { $params = array ( //此处作了修改 'accesskey' => $this->accesskey, 'secret' => $this->secret, 'sign' => $this->signName, 'templateId' => $this->templateId, 'mobile' => $mobile, 'content' => $verify_code.'##'.$minute ); $url = "http://api.1cloudsp.com/api/v2/single_send"; $data = http_build_query ( $params ); $ch = curl_init (); curl_setopt ( $ch, CURLOPT_URL, $url ); curl_setopt ($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/x-www-form-urlencoded', 'charset=utf-8')); curl_setopt($ch, CURLOPT_HEADER, 0);// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//要求结果为字符串且输出到屏幕上 curl_setopt($ch, CURLOPT_POST, 1);//post提交方式 curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec ( $ch ); curl_close ( $ch ); $result = json_decode ( $result, true ); if (isset ( $result ['Code'] )) { $this->error = $this->getErrorMessage ( $result ['Code'] ); return false; } return true; } }