2024年09月11日 建站教程
如何利用php语法和亿美短信接口实现短信发送功能,下面web建站小编给大家简单介绍一下具体实现代码!
具体代码如下:
<?php // 亿美短信接口账号信息 $ym_sms_api_url = "http://sdk4rptws.eucp.b2m.cn:8080/sdkproxy/"; $ym_sms_account = "your_account"; $ym_sms_password = "your_password"; // 短信接收号码,多个号码用英文逗号分隔 $mobile_phone = "138********,139********"; // 短信内容 $sms_content = "您的验证码是:123456,请尽快使用。【公司名称】"; // 短信内容需进行UTF-8编码转换 $sms_content = urlencode(iconv("UTF-8","GB2312",$sms_content)); $post_data = "cdkey=".$ym_sms_account."&password=".$ym_sms_password."&phone=".$mobile_phone."&message=".$sms_content; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $ym_sms_api_url."sendsms.action"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); $response = curl_exec($ch); curl_close($ch); // 输出短信发送结果 echo $response; ?>
本文链接:http://so.lmcjl.com/news/12777/