• 微信查询四六级成绩代码


    使用curl请求99宿舍接口查询,再调用微信客服接口返回信息。

        //四六级查询,方倍工作室出品
        public function cet_query(){
            $openid = I("post.openid");
            if ($_SERVER['HTTP_HOST'] != "www.fangbei.org"){
                $arr = array('info' => "非法调用,请关注方倍工作室官方账号进入查询");
            }else{
                $name = I("post.name");
                $number = I("post.number");
                $name_gb2312 = urlencode(mb_convert_encoding($name, 'gb2312', 'utf-8'));
                $data = "id=".$number."&name=".$name_gb2312;
    
                $url = "https://cet.99sushe.com/getscore".$number;
                $headers = array(
                "User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1",
                "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
                "Accept-Language: en-us,en;q=0.5",
                "Referer: http://cet.99sushe.com/"
                );
                $curl = curl_init();
                curl_setopt($curl, CURLOPT_URL, $url);
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
                curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,false);
                curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,false);
                curl_setopt($curl, CURLOPT_POST, 1);
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
                $output = curl_exec($curl);
                curl_close($curl);
    
                $result = iconv("GBK", "UTF-8//IGNORE", $output);
                $score = explode(",",$result);
                Vendor('Weixin.basicclass');
                $weixin = new weixin();
                if (count($score)>4){
                    $arr = array(
                        'info' => "姓名:".$score[6]."\n学校:".$score[5]."\n总分:".$score[4]
                    );
    
                    $data = array();
                    $type = substr($number,9,1);
                    $typestr = array("1"=>"四级","2"=>"六级");
                    $data[] = array("title"=>"CET成绩单", "description"=>"", "picurl"=>"", "url" =>"");
                    $data[] = array("title"=>"考生姓名:".$score[6]."
    学校名称:".$score[5], "description"=>"", "picurl"=>"", "url" =>"");
                    $data[] = array("title"=>"考试类别:".$typestr[$type]."
    准考证号:".$number, "description"=>"", "picurl"=>$orderArr["product_img"], "url" =>"");
                    $data[] = array("title"=>"听力部分:".$score[1]."
    阅读部分:".$score[2]."
    写作翻译:".$score[3]."
    成绩总分:".$score[4], "description"=>"", 
                    "picurl"=>($score[4] > 425)?"https://www.cnblogs.com/txw1958/ok.jpg":"https://www.cnblogs.com/txw1958/error.jpg", "url" =>"");
                    $data[] = array("title"=>"技术支持 方倍工作室", "description"=>"", 
                    "picurl"=>"", "url" =>"https://www.cnblogs.com/txw1958/");
                    $result2 = $weixin->send_custom_message($openid, "news", $data);
                }else{
                    $arr = array(
                        'info' => "姓名:".$score[6]."\n学校:".$score[5]."\n总分:".$score[4]
                    );
                    $result2 = $weixin->send_custom_message($openid, "text", "Error
    ".$name."
    ".$number);
                }
            }
    
    
            echo json_encode($arr);
        }
  • 相关阅读:
    Query实例的ajax应用之二级联动的后台是采用php来做的
    关于jquery的css的一些知识
    这个代码给所有带有name属性的链接加了一个背景色
    jQuery生成一个DIV容器,ID是"rating".
    被included或者被required的文件都来自哪里呢
    msql_createdb: 建立一个新的 mSQL 数据库。
    php中调用这个功能可以在web页面中显示hello world这个经典单词
    啦啦啦测试心得
    maven命令
    robotframework使用
  • 原文地址:https://www.cnblogs.com/txw1958/p/11141554.html
Copyright © 2020-2023  润新知