利用Google voice打造短信平台
时间:2009-10-24
来源:互联网
谷歌的全球免费SMS(短信)的服务。可以自己开发api作为自己的验证码发送?相关验证的的平台。
哪些苦于没有免费短信平台的同学可以考虑一下 google voice嘛。
google voice 比较难注册祝福你们~
[php]
class GoogleVoice
{
public $username;
public $password;
public $status;
private $lastURL;
private $login_auth;
private $inboxURL = 'https://www.google.com/voice/m/';
private $loginURL = 'https://www.google.com/accounts/ClientLogin';
private $smsURL = 'https://www.google.com/voice/m/sendsms';
public function __construct($username, $password)
{
$this->username = $username;
$this->password = $password;
}
public function getLoginAuth()
{
$login_param = "accountType=GOOGLE&Email={$this->username}&Passwd={$this->password}&service=grandcentral&source=lostleonATgmailDOTcom-GoogleVoiceTool";
$login_output = $this->curl($this->loginURL, $this->lastURL, $login_param);
$this->login_auth = $this->match('/Auth=([A-z0-9_-]+)/', $login_output, 1);
return $this->login_auth;
}
public function get_rnr_se()
{
$auth_param = "?auth=".$this->getLoginAuth();
$inbox_output = $this->curl($this->inboxURL.$auth_param, $this->lastURL);
$_rnr_se = $this->match('!<input.*?name="_rnr_se".*?value="(.*?)"!ms', $inbox_output, 1);
return $_rnr_se;
}
public function sms($to_phonenumber, $smstxt)
{
$_rnr_se = $this->get_rnr_se();
$sms_param = "id=&c=&number=".urlencode($to_phonenumber)."&smstext=".urlencode($smstxt)."&_rnr_se=".urlencode($_rnr_se);
$posturl = $this->smsURL."?auth=".$this->login_auth;
$sms_output = $this->curl($posturl, $this->lastURL, $sms_param);
$this->status = $sms_output;
return $sms_output;
}
private function curl($url, $referer = null, $post_param = null)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_2_1 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5H11 Safari/525.20");
if($referer)
curl_setopt($ch, CURLOPT_REFERER, $referer);
if(!is_null($post_param))
{
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_param);
}
$html = curl_exec($ch);
$this->lastURL = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
return $html;
}
private function match($regex, $str, $out_ary = 0)
{
return preg_match($regex, $str, $match) == 1 ? $match[$out_ary] : false;
}
}
[/php]
作者: 风吟 发布时间: 2009-10-24
必须加 86 不然无法发送成功.
作者: 风吟 发布时间: 2009-10-24
作者: qai41 发布时间: 2009-10-28
认为GOOGLE的理念和思路总是那么有前瞻性
做的东西不浮躁
作者: guxiaochuan 发布时间: 2009-10-29
作者: luckygang 发布时间: 2009-10-29
作者: yafeikf 发布时间: 2009-10-29
作者: bobxia 发布时间: 2009-10-29
不过,也不知这项服务,能免费多久的
作者: index 发布时间: 2009-10-30
作者: moorland 发布时间: 2009-10-30
作者: 风吟 发布时间: 2009-10-31
作者: xiaobai 发布时间: 2009-10-31
作者: hydata 发布时间: 2009-11-05
作者: libintm 发布时间: 2009-11-05
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28