短信发送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);
    }

打赏

本文固定链接: https://www.cxy163.net/archives/1593 | 绝缘体

该日志由 绝缘体.. 于 2018年01月02日 发表在 首页 分类下,
原创文章转载请注明: 短信发送by阿里大鱼 | 绝缘体

报歉!评论已关闭.