获取客服聊天记录怎么弄?

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);
        }

  

你可能感兴趣的:(获取)