日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

sae php 短信,中国电信翼聊短信PHP发送类实现详细代码

發布時間:2024/1/1 php 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 sae php 短信,中国电信翼聊短信PHP发送类实现详细代码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

中國電信翼聊短信可以向三網用戶發送短信,每天對每一個號碼可以最多發送5條短信,當發送5條短信的時候會出現驗證碼,但是只要輸入一次驗證碼之后就可以繼續使用,不再需要輸入驗證碼,所以還是有一定實用價值的。下面是PHP 翼聊短信發送類源代碼。暫不支持放置在多出口的主機上,因為翼聊短信是單點登錄的,限制只有一個用戶和一個IP在線,所以SAE環境無法非常正常的使用,會有間歇性故障,原因是出口IP問題。

下面就是代碼了

/*

*翼聊短信發送類,由于翼聊短信限制,非電信用戶每天對每個號碼不能發送5條以上的短信,發送多條時會出現驗證碼,所以會發送失敗;

*其實只要輸入驗證碼就好了,反正翼聊短信也就驗證一次驗證碼~

*Author:CplusHua

*/

Class smsPush{

public $PhoneNum;

public $vcode;

public $cookie;

function __construct($PhoneNum=null){

if(null==$PhoneNum) echo '您沒有設置發送者手機號碼,這樣是發不出短信滴~';

$this->PhoneNum=$PhoneNum;

}

function __get($var){

return $this->$var;

}

function getVcode($PhoneNum=null){

if($PhoneNum==null&& $this->PhoneNum!=null) $PhoneNum=$this->PhoneNum;

else if($PhoneNum==null) return false;

$url='http://115.239.133.251:6090/imweb/phoneCheckCode.s?

0.9838632841128856&sendPhone='.$PhoneNum.'&methodType=getPhoneCode';

$option=array(

CURLOPT_URL=>$url,

CURLOPT_POST=>false,

CURLOPT_RETURNTRANSFER=>true,

//CURLOPT_HEADER=>true,

);

$result=$this->exec($option);

$this->saveCookie($this->cookie);

if(100==$result) return true;

else return false;

}

function SubmitVcode($PhoneNum=null,$vcode=null){

if(null==$vcode) $vcode=$this->vcode;

if(null==$PhoneNum) $PhoneNum=$this->PhoneNum;

$this->cookie='JSESSIONID=

C72FD92F73AB532C0676565D2D8B7971;loginType=1; firsstYZ=yes';

$option=array(

CURLOPT_URL=>'http://115.239.133.251:6090/imweb/codeLogin.s?clientId=46&

account='.$PhoneNum.'&checkCode='.$vcode.'&rid=0.19796998496167362',

CURLOPT_COOKIE=>$this->cookie,

CURLOPT_HEADER=>true,

CURLOPT_RETURNTRANSFER=>true,

);

$result=$this->exec($option);

preg_match_all('/\nSet-Cookie:\s(.*)\s\n[\w|\W]*({"code":"100",

"loginSessionInfo":{.*})/i', $result, $matches);

//print_r($matches);//echo $matches[0][1];

$res=json_decode($matches[2][0]);

// print_r($res);

if(100!=$res->code) return false;

$this->cookie=$matches[1][0];

$this->saveCookie($this->cookie);

return true;

}

function exec($option=array()){

if(empty($option)) return false;

$c=curl_init();

curl_setopt_array($c, $option);

$res=curl_exec($c);

curl_close($c);

return $res;

}

function sendSMS($receivePhone=null,$msg=null,$checkCode=null){

if(null==$receivePhone||null==$msg) return false;

$data='&checkCode='.$checkCode.'&receivePhone='.$receivePhone.'&

smsContent='.$msg.'&random=0.7006821087561548';

$this->readCookie();

$this->cookie.=';loginType=1; firsstYZ=yes';

//echo $this->cookie;

$option = array(

CURLOPT_URL =>'http://115.239.133.251:6090/imweb/smsPush.s?clientId=46' ,

CURLOPT_POST=>true,

CURLOPT_POSTFIELDS=>$data,

CURLOPT_COOKIE=>$this->cookie,

CURLOPT_RETURNTRANSFER=>true,

);

$result=$this->exec($option);echo $result;

if(101==$result){

echo "這個IP還未登錄,如果您是用在了分布式服務器,那么肯定是因為出口的IP不一樣了~";

return $result;

}

if(104==$result){

echo "發送次數超限!";

return $result;

}

if(201==$result) {

echo '請輸入驗證碼!就這樣悲劇了~';//其實就輸入一次,抓取回來輸入進去不就完事了嘛~ 人家翼聊短信是記錄IP的,不要用多IP的服務器,否則悲劇了~

return $result;

}

if(100==$result) return true;

else return $result;

}

function sae_saveCookie($string){

$mmc=memcache_init();

if($mmc==false){

echo "mc init failed\n"; return 0;

}

else

{

return memcache_set($mmc,$this->PhoneNum,$string);

}

}

function sae_readCookie(){

$mmc=memcache_init();

if($mmc==false){

echo "mc init failed\n"; return 0;

}

else

{

return memcache_get($mmc,$this->PhoneNum);

}

}

//雖然兼容了SAE環境的寫cookie問題,但是SAE是多線出口,所以沒有辦法保證每次的出口IP都一樣。使用該cookie,出口IP不同的時候是無法使用的

function saveCookie($string){

if(!empty($_SERVER['HTTP_APPNAME'])&&!empty

($_SERVER['HTTP_APPVERSION'])) return $this->sae_saveCookie($string);

$f=fopen($this->PhoneNum.'.txt', 'w');

return fwrite($f, $string);

}

function readCookie(){

if(isset($_SERVER['HTTP_APPNAME'])&&isset

($_SERVER['HTTP_APPVERSION']))

{ $this->cookie= $this->sae_readCookie(); return 1;}

if(filesize($this->PhoneNum.'.txt')){

$f=fopen($this->PhoneNum.'.txt', 'r');

$cookie=fread($f, filesize($this->PhoneNum.'.txt'));

if(!empty($cookie)) return $this->cookie=$cookie;

}

}

function setImgcode(){

}

function getImg($imgurl="

http://115.239.133.251:6090/imweb/imageServlet.s",

$reffer="http://liao.189.cn/"){

$this->readCookie();

$this->cookie.=';loginType=1; firsstYZ=yes';

//echo $this->cookie;

$option = array(

CURLOPT_URL =>$imgurl ,

CURLOPT_RETURNTRANSFER=>true,

CURLOPT_HEADER=>0,

CURLOPT_USERAGENT=>'Mozilla/4.0 (compatible; MSIE 7.0;

Windows NT 5.1; QQDownload 1.7; TencentTraveler 4.0',

CURLOPT_REFERER=>'http://liao.189.cn/',

CURLOPT_COOKIE=>$this->cookie,

CURLOPT_COOKIESESSION=>true,

);

$result=$this->exec($option);

header('Content-Type: image/jpeg');

echo $result;

return $result;

}

}

總結

以上是生活随笔為你收集整理的sae php 短信,中国电信翼聊短信PHP发送类实现详细代码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。