search
Homephp教程php手册企业级短信验证码,短信通知类,短信秒发送,秒到达哦

适合需要短信验证,手机绑定以及消息通知,订单查询,快递查询,货物派送等短信通知功能的网站使用
之前有写过基于电信能力开发平台的短信接口开发的短信发送类http://www.thinkphp.cn/code/625.html。已经有大半年了,好久都没更新了,很多朋友都在问它的使用方法,已经其他的一些问题,在这里说声抱歉啊,因为有点儿忙,都不怎么注意看消息的。sorry.现在送上企业级的短信验证码,以及短信通知类。注意哦,这个短信的及时性是很好的啊,比自谦的电信短信接口发送的短信快多了,还有的的可靠性等待都比之前的好很多。一般都是5秒这样就能到达了,最迟也是15秒而已。
本类是基于互亿短信互动平台的短信接口开发的,要使用本接口必须拥有互亿短信平台的账号。测试账号的短信测试条数为10条。<?php <br /> <br> class Sms {<br>     <br>     var $target ="http://106.ihuyi.cn/webservice/sms.php?method=Submit";//短信post提交地址;<br>     var $username='用户名';//互亿短信平台上注册的用户名,每个账号可以获得10条测试短信;<br>     var $password='密码';//密码;<br>     <br>     function __construct() {<br>         $this->Sms();<br>     }<br>     function Sms()<br>     {<br> <br>     }<br>     //curl post 方式提交请求获取响应信息。<br>     function Curl_Post($curlPost,$url){<br>         $curl = curl_init();<br>         curl_setopt($curl, CURLOPT_URL, $url);<br>         curl_setopt($curl, CURLOPT_HEADER, false);<br>         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);<br>         curl_setopt($curl, CURLOPT_NOBODY, true);<br>         curl_setopt($curl, CURLOPT_POST, true);<br>         curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);<br>         $return_str = curl_exec($curl);<br>         curl_close($curl);<br>         return $return_str;<br>     }<br>     //将xml格式的数据转化成为数组<br>     function xml_to_array($xml){<br>         $reg = "/]*>([\\x00-\\xFF]*)/";<br>         if(preg_match_all($reg, $xml, $matches)){<br>             $count = count($matches[0]);<br>             for($i = 0; $i              $subxml= $matches[2][$i];<br>             $key = $matches[1][$i];<br>                 if(preg_match( $reg, $subxml )){<br>                     $arr[$key] = $this->xml_to_array( $subxml );<br>                 }else{<br>                     $arr[$key] = $subxml;<br>                 }<br>             }<br>         }<br>         return $arr;<br>     }<br>     //短信发送函数,实际上调用的是Curl_Post 函数发送的,$mobile为发送的对象手机号,$msg为发送的内容,注意:$msg的模板内容必须经过了互亿短信平台的审核方可发送成功<br>     <br>     <br>     function send($mobile,$msg){<br>         $post_data = "account=".$this->username."&password=".$this->password."&mobile=".$mobile."&content=".rawurlencode($msg);//构造post数据<br>         $results =  $this->xml_to_array($this->Curl_Post($post_data,$this->target));<br>         if($results['SubmitResult']['code']==2){//返回码等于2的时候<br>             echo "发送成功!";<br>         }else{<br>             echo '发送失败!'.$results['SubmitResult']['code'];<br>         }<br>     }<br>   }<br> <br> ?>[url][/url]

附件 Sms.zip ( 1.18 KB 下载:176 次 )

AD:真正免费,域名+虚机+企业邮箱=0元

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool