2023年7月31日发(作者:)

⼀信通短信接⼝对接_短信接⼝对接流程下⾯是php开发语⾔短信接⼝接⼊到项⽬中的demo⽰例:// ① 该代码仅供接⼊动⼒思维乐信短信接⼝参考使⽤,客户可根据实际需要⾃⾏编写;// ② ⽀持发送验证码短信、触发通知短信等;// ③ 测试验证码短信、通知短信,请⽤默认的测试模板,默认模板详见接⼝⽂档。class SendUtility {private $_config = array();/*** 获取相关配置* ⽂件中的乐信⽤户名、密码、签名*/public __construct($config) {$this->_config = $config;}/*** 拼接请求参数*/function BuildContent($AimMobiles, $Content) {$str = "accName=" . urlencode($this->_config["UserName"]);$str .= "&accPwd=" . urlencode(strtoupper(md5($this->_config["Password"])));$str .= "&aimcodes=" . urlencode($AimMobiles);$str .= "&content=" . urlencode($Content . $this->_config["Signature"]);return $str;}/*** 短信发送* @param $AimMobiles 下⾏⼿机号* @param $Content 短信内容*/function Send($AimMobiles, $Content) {$content = $this->BuildContent($AimMobiles, $Content);$counter = 0;while ($counter < count($this->_config["Addresses"])) {$opts = array('http' => array("method" => "POST", "timeout" => $this->_config["HttpTimeout"],"header" => "Content-type: application/x-www-form-urlencoded", "content" => $content));$message = file_get_contents($this->_config["Addresses"][$counter] . "/send", false,stream_context_create($opts));if ($message == false) $counter++;else break;}if ($message == false) return "发送失败";$RtnString = explode(";", $message);if ($RtnString[0] != "1") return $RtnString[1];return $RtnString[0];}/*** 余额查询* @param $accName ⽤户名* @param $accPwd 密码*/function Query() {$content = "accName=" . urlencode($this->_config["UserName"]);$content .= "&accPwd=" . urlencode(strtoupper(md5($this->_config["Password"])));$opts = array('http' => array("method" => "POST","header" => "Content-type: application/x-www-form-urlencoded","content" => $content));$message = file_get_contents($this->_config["Addresses"][0] . "/qryBalance", false,stream_context_create($opts));if ($message == false) return "查询失败";$RtnString = explode(";", $message);if ($RtnString[0] != "1") return $RtnString[1];return $RtnString[2];}}php>

2023年7月31日发(作者:)

⼀信通短信接⼝对接_短信接⼝对接流程下⾯是php开发语⾔短信接⼝接⼊到项⽬中的demo⽰例:// ① 该代码仅供接⼊动⼒思维乐信短信接⼝参考使⽤,客户可根据实际需要⾃⾏编写;// ② ⽀持发送验证码短信、触发通知短信等;// ③ 测试验证码短信、通知短信,请⽤默认的测试模板,默认模板详见接⼝⽂档。class SendUtility {private $_config = array();/*** 获取相关配置* ⽂件中的乐信⽤户名、密码、签名*/public __construct($config) {$this->_config = $config;}/*** 拼接请求参数*/function BuildContent($AimMobiles, $Content) {$str = "accName=" . urlencode($this->_config["UserName"]);$str .= "&accPwd=" . urlencode(strtoupper(md5($this->_config["Password"])));$str .= "&aimcodes=" . urlencode($AimMobiles);$str .= "&content=" . urlencode($Content . $this->_config["Signature"]);return $str;}/*** 短信发送* @param $AimMobiles 下⾏⼿机号* @param $Content 短信内容*/function Send($AimMobiles, $Content) {$content = $this->BuildContent($AimMobiles, $Content);$counter = 0;while ($counter < count($this->_config["Addresses"])) {$opts = array('http' => array("method" => "POST", "timeout" => $this->_config["HttpTimeout"],"header" => "Content-type: application/x-www-form-urlencoded", "content" => $content));$message = file_get_contents($this->_config["Addresses"][$counter] . "/send", false,stream_context_create($opts));if ($message == false) $counter++;else break;}if ($message == false) return "发送失败";$RtnString = explode(";", $message);if ($RtnString[0] != "1") return $RtnString[1];return $RtnString[0];}/*** 余额查询* @param $accName ⽤户名* @param $accPwd 密码*/function Query() {$content = "accName=" . urlencode($this->_config["UserName"]);$content .= "&accPwd=" . urlencode(strtoupper(md5($this->_config["Password"])));$opts = array('http' => array("method" => "POST","header" => "Content-type: application/x-www-form-urlencoded","content" => $content));$message = file_get_contents($this->_config["Addresses"][0] . "/qryBalance", false,stream_context_create($opts));if ($message == false) return "查询失败";$RtnString = explode(";", $message);if ($RtnString[0] != "1") return $RtnString[1];return $RtnString[2];}}php>