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

      

  • 相关阅读:
    CGI(通用网关接口)
    PHP简介
    SEO搜索引擎优化/URL
    使用表单标签,与用户交互
    认识<img>标签,为网页插入图片
    使用mailto在网页中链接Email地址
    使用<a>标签,链接到另一个页面
    1037. Magic Coupon (25)
    1038. Recover the Smallest Number (30)
    1034. Head of a Gang (30) -string离散化 -map应用 -并查集
  • 原文地址:https://www.cnblogs.com/GmrBrian/p/3801195.html
Copyright © 2011-2022 走看看