微信查询四六级成绩代码

使用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]."\n学校名称:".$score[5], "description"=>"", "picurl"=>"", "url" =>"");
                $data[] = array("title"=>"考试类别:".$typestr[$type]."\n准考证号:".$number, "description"=>"", "picurl"=>$orderArr["product_img"], "url" =>"");
                $data[] = array("title"=>"听力部分:".$score[1]."\n阅读部分:".$score[2]."\n写作翻译:".$score[3]."\n成绩总分:".$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\n".$name."\n".$number);
            }
        }


        echo json_encode($arr);
    }

 

转载于:https://www.cnblogs.com/txw1958/p/11141554.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值