🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
>[info]## 3.1请求示例 (POST) ```php $user_account= 'api2@sms@123'; //短信平台帐号 $secret = '202cb962ac59075b964b07152d234b701'; //短信平台密码 $template_sign= '短信通'; //短信签名,不写默认'短信通' $account_arr = explode('@',$user_account); if(count($account_arr)!=3) return false; $account = $account_arr[2];//取账号api2@sms@123中的123作为接口账号参数 $template_code='SMS_106600025';//短信模板 $phone=13413783062; $template_param=json_encode(array('code'=>123123));//短信内容 $host = "http://{$account_arr[0]}.kemanduo.net/v2/api/sms/send"; //也就是http://api2.kemanduo.net/v2/api/sms/send,这样写便于API升级后代码依然可用 $dev_id = 110000; //开发者ID $request_id = md5(time() . mt_rand(100000, 999999)); //请求编号 $sign = md5(md5($account . $secret) . $request_id);//加密的密钥签名 $request_url = $_SERVER["REQUEST_SCHEME"] . '://' . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"] . $_SERVER['QUERY_STRING']; //当前的详细请求地址 $curl = curl_init(); // 參数数组 $data = array( 'account' => $account, 'sign' => $sign, 'request_url' => $request_url, 'template_sign' => $template_sign, 'dev_id' => $dev_id, 'request_id' => $request_id,//请求id,唯一,32位 'template_code' => $template_code,//短信模板 'phone' =>$phone, 'template_param' =>$template_param             ); $headers = array(); curl_setopt($curl, CURLOPT_URL, $host); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_HEADER, 0); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_FAILONERROR, 1); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); if (1 == strpos("$" . $host, "https://")) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); } $result = curl_exec($curl);//接口数据返回 ```