php实现发送短信实例

小云云
Lepaskan: 2023-03-22 18:22:01
asal
3596 orang telah melayarinya

本文主要和大家分享php实现发送短信实例,主要以代码的方式和大家分享,希望能帮助到大家。

1.调用alidayu的工具类包,然后配置参数

  public function sendSMS ($mobile, $content,$type,$pcode,$address)
{
    include("TopSdk.php");
    date_default_timezone_set('Asia/Shanghai');    $c = new \TopClient();
    switch ($type){        case '1':            $c->appkey = "*****";            $c->secretKey = "************";            //$req = new AlibabaAliqinFcSmsNumSendRequest;
            $req = new \AlibabaAliqinFcSmsNumSendRequest();            $req->setSmsType("normal");            $req->setSmsFreeSignName("好运生活");            $req->setSmsParam("{\"village\":\"".$content."\",\"pcode\":\"".$pcode."\",\"address\":\"".$address."\"}");            $req->setRecNum($mobile);            $req->setSmsTemplateCode("SMS_127161604");            $resp = $c->execute($req);
            break;
        default :            $c->appkey = "*****";            $c->secretKey = "**********";            //$req = new AlibabaAliqinFcSmsNumSendRequest;
            $req = new \AlibabaAliqinFcSmsNumSendRequest();            $req->setSmsType("normal");            $req->setSmsFreeSignName("顺手拿");            $req->setSmsParam("{\"code\":\"".$content."\",\"product\":\"shunshouna\"}");            $req->setRecNum($mobile);            $req->setSmsTemplateCode("SMS_33580526");            $resp = $c->execute($req);
            break;
    }    if($resp->result->success){        return true;
    }    else{        return false;
    }
}
Salin selepas log masuk
Salin selepas log masuk

2.调用sendSMS方法.并进行处理.

 $res = (new Aliyun())->sendSMS($this->_param['mobile'],$this->_param['village'],1,$this->_param['p_code'],$this->_param['address']);
Salin selepas log masuk
Salin selepas log masuk

1.调用alidayu的工具类包,然后配置参数

  public function sendSMS ($mobile, $content,$type,$pcode,$address)
{
    include("TopSdk.php");
    date_default_timezone_set('Asia/Shanghai');    $c = new \TopClient();
    switch ($type){        case '1':            $c->appkey = "*****";            $c->secretKey = "************";            //$req = new AlibabaAliqinFcSmsNumSendRequest;
            $req = new \AlibabaAliqinFcSmsNumSendRequest();            $req->setSmsType("normal");            $req->setSmsFreeSignName("好运生活");            $req->setSmsParam("{\"village\":\"".$content."\",\"pcode\":\"".$pcode."\",\"address\":\"".$address."\"}");            $req->setRecNum($mobile);            $req->setSmsTemplateCode("SMS_127161604");            $resp = $c->execute($req);
            break;
        default :            $c->appkey = "*****";            $c->secretKey = "**********";            //$req = new AlibabaAliqinFcSmsNumSendRequest;
            $req = new \AlibabaAliqinFcSmsNumSendRequest();            $req->setSmsType("normal");            $req->setSmsFreeSignName("顺手拿");            $req->setSmsParam("{\"code\":\"".$content."\",\"product\":\"shunshouna\"}");            $req->setRecNum($mobile);            $req->setSmsTemplateCode("SMS_33580526");            $resp = $c->execute($req);
            break;
    }    if($resp->result->success){        return true;
    }    else{        return false;
    }
}
Salin selepas log masuk
Salin selepas log masuk

2.调用sendSMS方法.并进行处理.

 $res = (new Aliyun())->sendSMS($this->_param['mobile'],$this->_param['village'],1,$this->_param['p_code'],$this->_param['address']);
Salin selepas log masuk
Salin selepas log masuk

相关推荐:

php实现发送短信

php使用短信宝发送短信的方法

PHP发送短信邮件等众多实用PHP代码分享

Atas ialah kandungan terperinci php实现发送短信实例. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!