+ -
当前位置:首页 → 问答吧 → 利用Google voice打造短信平台

利用Google voice打造短信平台

时间:2009-10-24

来源:互联网

本帖最后由 风吟 于 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]

作者: 风吟   发布时间: 2009-10-24

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

必须加 86 不然无法发送成功.

作者: 风吟   发布时间: 2009-10-24

先记录下来,这玩意下来移动会疯了的

作者: qai41   发布时间: 2009-10-28

很喜欢GOOGLE的一些东西

认为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