$v) $fields[]=$k.'='.urlencode(stripslashes($v)); return implode('&',$fields); } function googleapi($url,$post=null){ global $auth; $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,$url); if(is_array($post)){ curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_POSTFIELDS,query($post)); } if($auth) curl_setopt($ch,CURLOPT_HTTPHEADER,array('Authorization: GoogleLogin auth='.$auth)); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,2); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); $data=curl_exec($ch) or curl_error($ch); curl_close($ch); return $data; } $auth=googleapi('https://www.google.com/accounts/ClientLogin',array( 'accountType'=>'GOOGLE', 'Email'=>GOOGLE_ACCOUNT, 'Passwd'=>GOOGLE_PASSWORD, 'service'=>'grandcentral', 'source'=>'googlevoice.php')); if(preg_match('/Error=([A-z]+)/',$auth,$error)) die($error[1]); if(preg_match('/Auth=([A-z0-9_-]+)/',$auth,$auth)) $auth=$auth[1]; preg_match("/'_rnr_se'\: '([^']+)'/",googleapi('https://www.google.com/voice/'),$rnr); $rnr=$rnr[1]; function call($them,$me){ global $rnr; return googleapi('https://www.google.com/voice/call/connect/',array( 'outgoingNumber'=>$them, 'forwardingNumber'=>$me, 'subscriberNumber'=>'undefined', 'phoneType'=>2, 'remember'=>'0', '_rnr_se'=>$rnr) ); } function hangup(){ global $rnr; return googleapi('https://www.google.com/voice/call/cancel/',array( 'outgoingNumber'=>'undefined', 'forwardingNumber'=>'undefined', 'cancelType'=>'C2C', '_rnr_se'=>$rnr) ); } function sms($them,$text){ global $rnr; return googleapi('https://www.google.com/voice/sms/send/',array( 'id'=>'', 'phoneNumber'=>$them, 'text'=>$text, '_rnr_se'=>$rnr) ); } // Place a call: call(Their Number,Your Number); // call(9135555555,3165555555); // hangup(); // Send an SMS: sms(Their Number,Message); // sms(9135555555,'Hello!'); ?>