zoukankan      html  css  js  c++  java
  • 获取客服聊天记录怎么弄?

    require_once 'apiAccess_token.php';
            //require_once  'apiOpenid.php';
            require_once '../../includes/config.inc.php';
            header('Content-Type: text/html; charset=utf-8');
            error_reporting(0);
            if(!empty($access_token)){
                    $sql = "select openid from `weiuser` ";
                    $openid = $mysqli->get($sql) ;
                    echo "<pre>";
                    $num =ceil(count($openid));
                    $sql = "insert into `weijilu`('worker','opercode','openid','time','text')";
                    for($i=0;$i<$num;$i++){
                            $openid1 = $openid[$i]['openid'];
                            
                            $url="https://api.weixin.qq.com/cgi-bin/customservice/getrecord?access_token=$access_token";                
                            $arr=array(
                                            
                                            "starttime" =>123456789,
                                            "endtime" => 987654321,
                                            "openid" => "$openid1",
                                            "pagesize" => 10,
                                            "pageindex" => 1,
                                            );
                            
                            $json = json_encode($arr);
                            p($url);
                            p($arr);
                            p($json);
                            $ch = curl_init();
                            curl_setopt($ch, CURLOPT_URL, $url);
                            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
                            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
                            curl_setopt($ch, CURLOPT_POST, 1);
                            curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
                            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                            $output = curl_exec($ch);
                            curl_close($ch);
                            $jsoninfo = json_decode($output, true);
                            $worker = $jsoninfo['recordlist']['worker'];
                            $opercode = $jsoninfo['recordlist']['opercode'];
                            $time = $jsoninfo['recordlist']['time'];
                            $text = $jsoninfo['recordlist']['text'];
                            
                            p($output);
                            
                            
                            if(!empty($worker) && !empty($opercode) && !empty($time) && !empty($text)){
                                    echo 111;
                                    $sql.="value('".$worker."','".$opercode."','".$openid1."','".$time."','".$text."')";
                            }else{
                                    echo  "暂时没有聊天记录";
                                    return false;
                            }
                    }
                            $mysqli -> execute($sql);
            }
    

      

  • 相关阅读:
    postman+newman+jenkins 接口自动化问题
    rabbitMQ Management http://localhost:15672/ 打不开
    转-轻松几步搭建SVN服务器
    Eclipse调优
    转- 关于时间,日期,星期,月份的算法(Java中Calendar的使用方法)
    calculate Leave Days
    验证只能输入中文
    js 只能限制只能输入数字和转大写方法
    拿来自勉
    JAVA的容器---List,Map,Set的区别
  • 原文地址:https://www.cnblogs.com/GmrBrian/p/3801195.html
Copyright © 2011-2022 走看看