短信发送by阿里大鱼
//短信发送by阿里大鱼
function AliSmsSend($phone = ”, $array = array(), $sms_template_code = ”, $sms_sign = ”)
{
global $cfg_ali_sms_appkey, $cfg_ali_sms_secret, $cfg_ali_sms_template_code, $cfg_ali_sms_sign;
$sms_template_code = empty($sms_template_code) ? $cfg_ali_sms_template_code : $sms_template_code;
$sms_sign = empty($sms_sign) ? $cfg_ali_sms_sign : $sms_sign;
if (empty($phone) || !is_array($array)) {
return false;
}
$Params = array(
‘PhoneNumbers’ => $phone,
‘SignName’ => $sms_sign,
‘TemplateCode’ => $sms_template_code,
‘TemplateParam’ => json_encode($array),
‘OutId’ => ”,
‘SmsUpExtendCode’ => ”,
‘RegionId’ => ‘cn-hangzhou’,
‘Action’ => ‘SendSms’,
‘Version’ => ‘2017-05-25’,
‘SignatureMethod’ => ‘HMAC-SHA1’,
‘SignatureNonce’ => uniqid(mt_rand(0, 0xffff), true),
‘SignatureVersion’ => ‘1.0’,
‘AccessKeyId’ => $cfg_ali_sms_appkey,
‘Timestamp’ => gmdate(“Y-m-d\TH:i:s\Z”),
‘Format’ => ‘JSON’,
);
ksort($Params);
$sign = base64_encode(hash_hmac(“sha1”, “POST&%2F&” . urlencode(http_build_query($Params)), $cfg_ali_sms_secret . “&”, true));
$url = “https://dysmsapi.aliyuncs.com/”;
$Params[‘Signature’] = $sign;
return CurlPost($url, $data);
}
最活跃的读者