thinkphp引入 阿里大于短信平台

public function alimsg(){

$appkey = "";//你的App key
$secret = "";//你的App Secret: 
vendor('Alimsg.top.TopClient');
vendor('Alimsg.top.ResultSet');
vendor('Alimsg.top.RequestCheckUtil');
vendor('Alimsg.top.TopLogger');
vendor('Alimsg.top.request.AlibabaAliqinFcSmsNumSendRequest'); 
$c = new \TopClient;
$c->appkey = $appkey;
$c->secretKey = $secret;
$req = new \AlibabaAliqinFcSmsNumSendRequest;
$req->setExtend("123456");//确定发给的是哪个用户,参数为用户id
$req->setSmsType("normal");
/*
进入阿里大鱼的管理中心找到短信签名管理,输入已存在签名的名称,这里是身份验证。
*/
$req->setSmsFreeSignName("短信测试");
$req->setSmsParam("{'num':'23123'}"); 
//这里设定的是发送的短信内容:验证码${code},您正在进行${product}身份验证,打死不要告诉别人哦!”
$req->setRecNum("xxxxxxx");//参数为用户的手机号码
$req->setSmsTemplateCode("SMS_132026199");
$resp = $c->execute($req);

var_dump($resp);

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
基于thinkphp5扩展的阿里大鱼短信接口。 使用方式: 1:将压缩包解压到项目根目录下simplewind文件夹下的extend文件夹中。 2:在use think\config文 件中加入配置 'wechat' =>array( /**********阿里大鱼配置************/ 'all_appkey' => '',//阿里大鱼Appkey 'all_secret' => '',//阿里大鱼Secret 'domain' => 'dysmsapi.aliyuncs.com',//阿里大鱼产品域名 'product' => 'Dysmsapi',////产品名称:云通信流量服务API产品,开发者无需替换 'region' => 'cn-hangzhou',//暂时不支持多Region 'end'=>'cn-hangzhou',// 服务结点 ), 3:在公共函数文件头部中加入 use aliyun\api_demo; 然后添加以下的阿里云调用方法: /**********************************发送短信--阿里大鱼********************/ /** * @param $autograph //签名 * @param $model //短信模板 * @param $phone //短信接收号码 * @param array $array //短信模板内容 * @param $water //流水号 * @return api_demo\stdClass|string */ function sk_aldayuCode($autograph,$model,$phone,$array=array(),$water){ if(!$autograph || !$model || !$phone || empty($array) || !$water){ return "参数不齐全:".$autograph."|".$model."|".$phone."|".$water; } $response = api_demo\SmsDemo::sendSms($autograph,$model,$phone,$array,$water); if(!$response->Message || $response->Message != 'OK'){ $msg['Message'] = $response->Message; return json_encode($msg,JSON_UNESCAPED_UNICODE); }else{ $msg['code'] = $array; $msg['Message'] = "OK"; return json_encode($msg,JSON_UNESCAPED_UNICODE); } } /**********************************发送短信--阿里大鱼********************/ 4:在须要调用短信发送的类中直接调用上方的函数。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值