免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3204 | 回复: 1
打印 上一主题 下一主题

微信客服之qq消息提醒 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-07-02 11:04 |只看该作者 |倒序浏览
当用户有消息进入微信公众平台,让接口自动回复消息到客服QQ上,达到及时回复的目的
QQ推送消息部分
  1. <?php

  2. /*******************************************
  3. 发送QQ信息PHP接口
  4. *******************************************/

  5. $sendQQ = new QQ('*******','***********');
  6. $sid = $sendQQ->login();
  7. $sendQQ->send('******','信息',$sid);




  8. class QQ {
  9.   public $id;
  10.   public $password;
  11.   public $error=array();
  12.   public $ssid;
  13.   private $cache;
  14.   public function QQ($id,$password,$ssid=null){
  15.     $this->id=$id;
  16.     $this->password=$password;
  17.     $ssid and file_put_contents($this->cache,$ssid);
  18.   }
  19.      
  20.      
  21.      
  22.   public function login(){
  23.     $r=QQ::ajax(
  24.       'http://pt.3g.qq.com/psw3gqqLogin',
  25.       array(
  26.         qq=>$this->id,pwd=>$this->password,
  27.         loginType=>1,i_p_w=>'qq|pwd|',
  28.         toQQchat=>'true',bid_code=>'3GQQ',
  29.         aid=>'nLoginHandle'
  30.       )
  31.     );
  32.     if(preg_match('/成功[\s\S]+sid=([^&]+)/',$r,$m)){
  33.       return $this->ssid=$m[1];
  34.     }else{
  35.       $this->error[]=$r;
  36.       return false;
  37.     };
  38.   }
  39.          
  40.      
  41.   public function send($qq,$message){
  42.     $retry=3;
  43.     while($retry--){
  44.       $r=QQ::ajax(
  45.         'http://q16.3g.qq.com/g/s?sid='.$this->ssid,
  46.         array(
  47.           msg=>$message,num=>$qq,'do'=>'send',u=>$qq,
  48.           'saveURL'=>'0',aid=>'发送QQ消息',on=>1
  49.         )
  50.       );
  51.       if(preg_match('/消息发送成功/',$r))return true;
  52.       $this->error[]=$r;
  53.       $this->login();
  54.     };
  55.     return false;
  56.   }
  57.      
  58.      
  59.      
  60.   private static function ajax($url,$data=null){
  61.     curl_setopt($c=curl_init($url),CURLOPT_RETURNTRANSFER,1);
  62.     $data and $data=http_build_query($data)
  63.           and curl_setopt($c,CURLOPT_POSTFIELDS,$data);
  64.     $s=curl_exec($c);
  65.     curl_close($c);
  66.     return $s;
  67.   }
  68. };


  69. ?>
复制代码

论坛徽章:
59
2015七夕节徽章
日期:2015-08-24 11:17:25ChinaUnix专家徽章
日期:2015-07-20 09:19:30每周论坛发贴之星
日期:2015-07-20 09:19:42ChinaUnix元老
日期:2015-07-20 11:04:38荣誉版主
日期:2015-07-20 11:05:19巳蛇
日期:2015-07-20 11:05:26CU十二周年纪念徽章
日期:2015-07-20 11:05:27IT运维版块每日发帖之星
日期:2015-07-20 11:05:34操作系统版块每日发帖之星
日期:2015-07-20 11:05:36程序设计版块每日发帖之星
日期:2015-07-20 11:05:40数据库技术版块每日发帖之星
日期:2015-07-20 11:05:432015年辞旧岁徽章
日期:2015-07-20 11:05:44
2 [报告]
发表于 2015-07-10 10:09 |只看该作者
能自动泡妞更好啊。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP