/** * @inheritdoc */ public function send($mobile, $content) { if (parent::send($mobile, $content)) { return true; } $data = ['action' => 'sendsms', 'username' => $this->username, 'userpwd' => $this->password, 'mobiles' => $mobile, 'content' => $content]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $this->state = (string) curl_exec($ch); curl_close($ch); $success = false; switch ($this->state) { case '': case '-1': $this->message = '用户名或密码错误'; break; case '-2': $this->message = '余额不足'; break; case '-3': $this->message = '号码太长,不能超过1000条一次提交'; break; case '-4': $this->message = '无合法号码'; break; case '-5': $this->message = '内容包含关键字'; break; case '-6': $this->message = '内容太长,超过9条'; break; case '-7': $this->message = '内容为空'; break; case '-8': $this->message = '定时时间格式不对'; break; case '-9': $this->message = '修改密码失败'; break; case '-10': $this->message = '用户当前不能发送短信'; break; case '-11': $this->message = 'Action参数不正确'; break; case '-100': $this->message = '系统错误'; break; default: $this->message = '短信发送成功'; $success = true; break; } return $success; }
/** * @inheritdoc */ public function send($mobile, $content) { if (parent::send($mobile, $content)) { return true; } $data = ['uid' => $this->username, 'key' => $this->password, 'smsMob' => $mobile, 'smsText' => $content]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $this->state = (string) curl_exec($ch); curl_close($ch); $success = false; switch ($this->state) { case '': case '-1': $this->message = '没有该用户账户'; break; case '-2': $this->message = '接口密钥不正确'; break; case '-21': $this->message = 'MD5接口密钥加密不正确'; break; case '-3': $this->message = '短信数量不足'; break; case '-11': $this->message = '该用户被禁用'; break; case '-14': $this->message = '短信内容出现非法字符'; break; case '-4': $this->message = '手机号格式不正确'; break; case '-41': $this->message = '手机号码为空'; break; case '-42': $this->message = '短信内容为空'; break; case '-51': $this->message = '短信签名格式不正确'; break; case '-6': $this->message = 'IP限制'; break; default: $this->message = '短信发送成功'; $success = true; break; } return $success; }
/** * @inheritdoc */ public function send($mobile, $content) { if (parent::send($mobile, $content)) { return true; } $data = ['u' => $this->username, 'p' => md5($this->password), 'm' => $mobile, 'c' => $content]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $this->state = (string) curl_exec($ch); curl_close($ch); $success = false; switch ($this->state) { case '0': $this->message = '短信发送成功'; break; case '-1': $this->message = '参数不全'; break; case '-2': $this->message = '服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!'; break; case '30': $this->message = '密码错误'; break; case '40': $this->message = '账号不存在'; break; case '41': $this->message = '余额不足'; break; case '42': $this->message = '帐户已过期'; break; case '43': $this->message = 'IP地址限制'; break; case '50': $this->message = '内容含有敏感词'; break; case '51': $this->message = '手机号码不正确'; break; default: $this->message = '短信发送成功'; $success = true; break; } return $success; }
/** * @inheritdoc */ public function send($mobile, $content) { if (parent::send($mobile, $content)) { return true; } $data = ['uid' => $this->username, 'pwd' => $this->password, 'mobile' => $mobile, 'content' => $content]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $result = curl_exec($ch); curl_close($ch); $resultArr = []; parse_str($result, $resultArr); $this->state = isset($resultArr['stat']) ? (string) $resultArr['stat'] : null; $this->message = isset($resultArr['message']) ? (string) $resultArr['message'] : null; return $this->state === '100'; }
/** * @inheritdoc */ public function send($mobile, $content) { if (parent::send($mobile, $content)) { return true; } $data = ['apikey' => $this->apikey, 'mobile' => $mobile, 'text' => $content]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $result = curl_exec($ch); curl_close($ch); $json = json_decode($result); if ($json && is_object($json)) { $this->state = isset($json->code) ? (string) $json->code : null; $this->message = isset($json->msg) ? (string) $json->msg : null; } return $this->state === '0'; }
/** * @inheritdoc */ public function send($mobile, $content) { if (parent::send($mobile, $content)) { return true; } $data = ['account' => $this->username, 'pswd' => $this->password, 'mobile' => $mobile, 'msg' => $content, 'needstatus' => 'true']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); $result = curl_exec($ch); curl_close($ch); $result = preg_split("/[,\r\n]/", $result); $this->state = isset($result[1]) ? (string) $result[1] : null; $success = false; switch ($this->state) { case '0': $this->message = '提交成功'; break; case '101': $this->message = '无此用户'; break; case '102': $this->message = '密码错'; break; case '103': $this->message = '提交过快'; break; case '104': $this->message = '系统忙'; break; case '105': $this->message = '敏感短信'; break; case '106': $this->message = '消息长度错'; break; case '107': $this->message = '包含错误的手机号码'; break; case '108': $this->message = '手机号码个数错'; break; case '109': $this->message = '无发送额度'; break; case '110': $this->message = '不在发送时间内'; break; case '111': $this->message = '超出该账户当月发送额度限制'; break; case '112': $this->message = '无此产品,用户没有订购该产品'; break; case '113': $this->message = 'extno格式错'; break; case '115': $this->message = '自动审核驳回'; break; case '116': $this->message = '签名不合法,未带签名'; break; case '117': $this->message = 'IP地址认证错,请求调用的IP地址不是系统登记的IP地址'; break; case '118': $this->message = '用户没有相应的发送权限'; break; case '119': $this->message = '用户已过期'; break; case '120': $this->message = '短信内容不在白名单中'; break; default: $this->message = '提交成功'; $success = true; break; } return $success; }