From 09dfe32eb6b538225686fd6ed0220240010bc574 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 1 Aug 2011 01:22:36 -0400 Subject: initial commit. Partway through a rewrite. I have some old files I didn't want to entirely delete. --- src/ext/GoogleVoice.class.php | 84 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/ext/GoogleVoice.class.php (limited to 'src/ext/GoogleVoice.class.php') diff --git a/src/ext/GoogleVoice.class.php b/src/ext/GoogleVoice.class.php new file mode 100644 index 0000000..9638416 --- /dev/null +++ b/src/ext/GoogleVoice.class.php @@ -0,0 +1,84 @@ +username = $username; + $this->password = $password; + } + + public function getLoginAuth() + { + $login_param = "accountType=GOOGLE&Email={$this->username}&Passwd={$this->password}&service=grandcentral&source=com.lostleon.GoogleVoiceTool"; + $ch = curl_init($this->loginURL); + 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"); + curl_setopt($ch, CURLOPT_REFERER, $this->lastURL); + curl_setopt($ch, CURLOPT_POST, "application/x-www-form-urlencoded"); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $login_param); + $html = curl_exec($ch); + $this->lastURL = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); + curl_close($ch); + $this->login_auth = $this->match('/Auth=([A-z0-9_-]+)/', $html, 1); + return $this->login_auth; + } + + public function get_rnr_se() + { + $this->getLoginAuth(); + $ch = curl_init($this->inboxURL); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $headers = array("Authorization: GoogleLogin auth=".$this->login_auth, 'User-Agent: 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'); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + $html = curl_exec($ch); + $this->lastURL = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); + curl_close($ch); + $_rnr_se = $this->match('!get_rnr_se(); + $sms_param = "id=&c=&number=".urlencode($to_phonenumber)."&smstext=".urlencode($smstxt)."&_rnr_se=".urlencode($_rnr_se); + $ch = curl_init($this->smsURL); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $headers = array("Authorization: GoogleLogin auth=".$this->login_auth, 'User-Agent: 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'); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_REFERER, $this->lastURL); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $sms_param); + $this->status = curl_exec($ch); + $this->lastURL = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); + curl_close($ch); + return $this->status; + } + + private function match($regex, $str, $out_ary = 0) + { + return preg_match($regex, $str, $match) == 1 ? $match[$out_ary] : false; + } +} +?> -- cgit v1.2.3-2-g168b