appid=$configs['appid']; $this->appkey=$configs['appkey']; if(!empty($configs['sign_type'])){ $this->sign_type=$configs['sign_type']; } } public function SetTo($address){ $this->To=trim($address); } public function SetProject($project){ $this->Project=$project; } public function AddVar($key,$val){ $this->Vars[$key]=$val; } public function buildRequest(){ $request=array(); $request['to']=$this->To; if(!empty($this->Addressbook)){ $request['addressbook']=''; foreach($this->Addressbook as $tmp){ $request['addressbook'].=$tmp.','; } $request['addressbook'] = substr($request['addressbook'],0,count($request['addressbook'])-2); } $request['project']=$this->Project; if(!empty($this->Vars)){ $request['vars']=json_encode($this->Vars); } return $request; } public function xsend(){ $voice_configs['appid']=$this->appid; $voice_configs['appkey']=$this->appkey; if($this->sign_type!=''){ $voice_configs['sign_type']=$this->sign_type; } $voice=new voice($voice_configs); return $voice->xsend($this->buildRequest()); } }