首页 | PHP资讯 | 技术专栏 | 资源共享 | PHP培训 | PHP职场 | 图书 | PHP ON WIN | PHP圈子
返回列表 回复 发帖

[原创] 利用Google voice打造短信平台

[原创] 利用Google voice打造短信平台

本帖最后由 风吟 于 2009-11-6 20:26 编辑

谷歌的全球免费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]
风吟博客 http://fengyin.name/
-------------------------------------
FY.JS库2.0 (类似Jquery语法) 只有2KB. 附带文档...
http://bbs.phpchina.com/thread-168853-1-3.html
-------------------------------------
QQ群:11206792 有大量PHP学习资料.欢迎来下.

注意!测试的时候手机移动要加 861xxxxxxxxx

必须加 86 不然无法发送成功.
风吟博客 http://fengyin.name/
-------------------------------------
FY.JS库2.0 (类似Jquery语法) 只有2KB. 附带文档...
http://bbs.phpchina.com/thread-168853-1-3.html
-------------------------------------
QQ群:11206792 有大量PHP学习资料.欢迎来下.

TOP

先记录下来,这玩意下来移动会疯了的
用心去模拟程序,用心去体会她的运行,用心去爱她。

TOP

很喜欢GOOGLE的一些东西

认为GOOGLE的理念和思路总是那么有前瞻性

做的东西不浮躁

TOP

能承载起 大量短信的发送吗???
人生需要导师

TOP

求代码
有技术,找项目?有项目,没技术?进群!51282556
小C的网窝 - 十七八岁的PHPer

TOP

同求

TOP

如果支持中文就更爽了。

不过,也不知这项服务,能免费多久的

TOP

哈哈,很好用呢.

TOP

永久免费
风吟博客 http://fengyin.name/
-------------------------------------
FY.JS库2.0 (类似Jquery语法) 只有2KB. 附带文档...
http://bbs.phpchina.com/thread-168853-1-3.html
-------------------------------------
QQ群:11206792 有大量PHP学习资料.欢迎来下.

TOP

返回列表