当用户有消息进入微信公众平台,让接口自动回复消息到客服qq上,达到及时回复的目的 weixinsdk ?php/*******************************************发送qq信息php接口 *******************************************/$sendqq = new qq('*******','***********')
当用户有消息进入微信公众平台,让接口自动回复消息到客服qq上,达到及时回复的目的 weixinsdk login();$sendqq->send('******','信息',$sid);class qq { public $id; public $password; public $error=array(); public $ssid; private $cache; public function qq($id,$password,$ssid=null){ $this->id=$id; $this->password=$password; $ssid and file_put_contents($this->cache,$ssid); } public function login(){ $r=qq::ajax( 'http://pt.3g.qq.com/psw3gqqlogin', array( qq=>$this->id,pwd=>$this->password, logintype=>1,i_p_w=>'qq|pwd|', toqqchat=>'true',bid_code=>'3gqq', aid=>'nloginhandle' ) ); if(preg_match('/成功[\s\s]+sid=([^&]+)/',$r,$m)){ return $this->ssid=$m[1]; }else{ $this->error[]=$r; return false; }; } public function send($qq,$message){ $retry=3; while($retry--){ $r=qq::ajax( 'http://q16.3g.qq.com/g/s?sid='.$this->ssid, array( msg=>$message,num=>$qq,'do'=>'send',u=>$qq, 'saveurl'=>'0',aid=>'发送qq消息',on=>1 ) ); if(preg_match('/消息发送成功/',$r))return true; $this->error[]=$r; $this->login(); }; return false; } private static function ajax($url,$data=null){ curl_setopt($c=curl_init($url),curlopt_returntransfer,1); $data and $data=http_build_query($data) and curl_setopt($c,curlopt_postfields,$data); $s=curl_exec($c); curl_close($c); return $s; }};?>