PHP 发送短信
#短信账号 const ACCOUNT = ''; #短信密码 const PASSWORD = ''; #短信路由 const API_SEND_URL = ' # 发送短信 function sendSMS($mobile, $msg, $needstatus = 'true') { $postArr = array( 'account' => self::ACCOUNT, 'password' => self::PASSWORD, 'msg' => $msg, 'phone' => $mobile ); $result = $this->curl(self::API_SEND_URL,'POST', $postArr); return $result; } # 调用接口 private function curl($url, $httpMethod = "GET", $data = '') { $json_template = json_encode($data); $ch = curl_init(); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpMethod); # 手动设置链接的头文件信息 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8')); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_POSTFIELDS, urldecode($json_template)); $notice = curl_exec($ch); curl_close($ch); return $notice; }