吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3382|回复: 26
收起左侧

[其他原创] 【PHP】全民K歌(K歌花园+歌房小镇+阳光农场)自动任务

  [复制链接]
newClass 发表于 2023-9-9 17:59


事已至此,先吃饭吧!
饭点到了

[PHP] 纯文本查看 复制代码
<?php
// 友情提示: 新手食用可能有难度!
$qmkg = new Qmkg;
$qmkg->anchorId = '*******'; // 房间的创始人艾迪  不是K歌号  也不是企鹅号  是什么号我也不知道 自行抓包获取  删了是防止被删帖.....
$qmkg->strRoomId = '39d9db8023253182364b74da'; // 房间艾迪 自行抓包获取
$qmkg->strShowId = '21989b8d2324358e374b18deb4c1cfcf6cb6f694b6d59acae5dc2f'; // 场景艾迪 自行抓包获取
$qmkg->cookie = ''; // 电脑打开 https://kg.qq.com/ >> 扫码登录 >> F12  >> 控制台输入“document.cookie” >> 回车即可获取
$res = $qmkg->cron();

Class Qmkg
{
    public $cookie = '';
    public $anchorId = '';
    public $strRoomId = '';
    public $strShowId = '';
    public $cwxrobot = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=0d9b8dc4-46db-46e2-95b5-*************'; // 企业微信群机器人通知地址

    public function cron(){
        $data = array(
            'uid' => $this->uid(),
            'appy_be_member' => array(
                'name' => '加入歌房会员',
                'result' => $this->social_ktv__member_webapp__appy_be_member(),
            ),
            'exchange_place_order' => array(
                'name' => '歌房小镇兑换',
                'result' => $this->ktv_small_town__farm_webapp__exchange_place_order(),
            ),
            'comm_store' => array(
                'name' => 'K歌花园兑换',
                'result' => $this->comm_store(),
            ),
            'garden' => array(
                'name' => 'K歌花园播种',
                'result' => $this->garden(),
            ),
            'farm' => array(
                'name' => '阳光农场',
                'result' => $this->farm(),
            ),
            'ktv_small_town' => array(
                'name' => '歌房小镇',
                'result' => $this->ktv_small_town(),
            ),
        );
        return $data;
    }

    // K歌花园
    private function garden(){
        $cache = $this->cache('kg_garden_'.$this->uid(),'au_qmkg');
        if($cache){return $cache;}
        $garden = $this->garden__webapp__info();
        if($garden['code'] == 0)
        {
            $landList = $garden['data']['garden.webapp.info']['garden']['landList'];
            $cron_garden = 60;
            foreach ($landList as $k => $v) {
                if($v['isActived'] == 1){
                    $leftTime = $v['seed']['leftTime'];
                    if($leftTime == 0){
                        $this->garden__webapp__harvest();
                        $rs = $this->garden__webapp__plant();
                        if($rs['subcode'] == '-10003'){
                            $this->cache('kg_garden_'.$this->uid(),'au_qmkg', $landList, 43200);
                        }
                        return $rs;
                    }
                    $cron_garden = $leftTime > $cron_garden ? $leftTime : $cron_garden;
                }
            }
            $this->cache('kg_garden_'.$this->uid(),'au_qmkg', $landList, $cron_garden);
            return $landList;
        }else{
            $this->send('error: '.$this->uid()." cookie Invalid !");
            return 'error: '.$this->uid()." cookie Invalid !";
        }
    }

    // K歌花园 检查兑换种子
    private function comm_store(){
        $cache = $this->cache('kg_garden_comm_store_'.$this->uid(),'au_qmkg');
        if($cache){return ['message'=>'今日已经兑换','cache'=>$cache];}
        $rs = $this->comm_store__webapp__list();
        if($rs['code'] == 0){
            $balance = $rs['data']['comm_store.webapp.list']['balance']; $leftNum = 0;
            $storeItemList = $rs['data']['comm_store.webapp.list']['storeItemList'];
            foreach ($storeItemList as $key => $v) {
                $leftNum += $v['leftNum'];
                if($v['leftNum'] > 0){
                    if($v['cost'] * $v['leftNum'] < $balance){
                        $res = $this->comm_store__webapp__exchange($v['itemId'], $v['leftNum']);
                        $balance = $balance - $v['cost'] * $v['leftNum'];
                    }else{
                        $this->cache('kg_garden_comm_store_'.$this->uid(),'au_qmkg', $storeItemList, strtotime(date('Y-m-d')) + 86400 - time());
                        return false; // 意思是最少需要有2000金币  不然不会执行兑换  只能自己兑换
                    }  
                }
            }
            $leftNum == 0 ? $this->cache('kg_garden_comm_store_'.$this->uid(),'au_qmkg', $storeItemList, strtotime(date('Y-m-d')) + 86400 - time()) : '';
        }
    }

    // K歌花园 兑换种子
    private function comm_store__webapp__exchange($t_itemId, $t_num)
    {
        $url = 'https://node.kg.qq.com/webapp/proxy?t_storeId=8&t_uid=' . $this->uid() . '&t_itemId=' . $t_itemId . '&t_num=' . $t_num . '&ns=proto_comm_store_webapp&cmd=comm_store.webapp.exchange&ns_inbuf=&cmdPrefix=&mapExt=JTdCJTIyZmlsZSUyMiUzQSU3QiUyMmZpbGVQYXRoUmVsYXRpdmVPdXRwdXQlMjIlM0ElMjJqY2VfbmV3JTJGa2clMkZjb21tX3N0b3JlJTJGcHJvdG9fY29tbV9zdG9yZV93ZWJhcHBfdjIuanMlMjIlMkMlMjJkZXBGaWxlUGF0aFJlbGF0aXZlT3V0cHV0JTIyJTNBJTVCJTVEJTdEJTJDJTIyY21kTmFtZSUyMiUzQSUyMlN0b3JlRXhjaGFuZ2VSZXElMjIlMkMlMjJ3bnNEaXNwYXRjaGVyJTIyJTNBdHJ1ZSU3RA%3D%3D&g_tk=5381&g_tk_openkey=245581372';
        $headers = array(
            'Host: node.kg.qq.com',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
            'Accept: application/json, text/plain, */*',
            'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Accept-Encoding: gzip, deflate, br',
            'Referer: https://kg.qq.com/',
            'Origin: https://kg.qq.com',
            'Sec-Fetch-Dest: empty',
            'Sec-Fetch-Mode: cors',
            'Sec-Fetch-Site: same-site',
            'Connection: keep-alive',
            'Cookie: ' . $this->cookie,
        );
        $rs = json_decode($this->request($url, 'GET', $headers),true);
        return $rs;
    }

    // K歌花园 查询剩余可兑换种子
    private function comm_store__webapp__list(){
        $url = 'https://node.kg.qq.com/webapp/proxy?t_storeId=8&t_uid=' . $this->uid() . '&t_num=20&t_typeId=1&t_passback=&ns=proto_comm_store_webapp&cmd=comm_store.webapp.list&ns_inbuf=&cmdPrefix=&mapExt=JTdCJTIyZmlsZSUyMiUzQSU3QiUyMmZpbGVQYXRoUmVsYXRpdmVPdXRwdXQlMjIlM0ElMjJqY2VfbmV3JTJGa2clMkZjb21tX3N0b3JlJTJGcHJvdG9fY29tbV9zdG9yZV93ZWJhcHBfdjIuanMlMjIlMkMlMjJkZXBGaWxlUGF0aFJlbGF0aXZlT3V0cHV0JTIyJTNBJTVCJTVEJTdEJTJDJTIyY21kTmFtZSUyMiUzQSUyMkNvbW1TdG9yZUxpc3RSZXElMjIlMkMlMjJ3bnNEaXNwYXRjaGVyJTIyJTNBdHJ1ZSU3RA%3D%3D&g_tk=5381&g_tk_openkey=245581372';
        $headers = array(
            'Host: node.kg.qq.com',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
            'Accept: application/json, text/plain, */*',
            'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Accept-Encoding: gzip, deflate, br',
            'Referer: https://kg.qq.com/',
            'Origin: https://kg.qq.com',
            'Sec-Fetch-Dest: empty',
            'Sec-Fetch-Mode: cors',
            'Sec-Fetch-Site: same-site',
            'Connection: keep-alive',
            'Cookie: ' . $this->cookie,
        );
        $rs = json_decode($this->request($url, 'GET', $headers),true);
        return $rs;
    }

    // K歌花园 获取种植信息
    private function garden__webapp__info(){
        $url = 'https://node.kg.qq.com/webapp/proxy';
        $url .= '?t_uid=' . $this->uid();
        $url .= '&ns=proto_garden_webapp&cmd=garden.webapp.info&g_tk=5381&g_tk_openkey=1469557487';
        $url .= '&mapExt=JTdCJTIyZmlsZSUyMiUzQSU3QiUyMmZpbGVQYXRoUmVsYXRpdmVPdXRwdXQlMjIlM0ElMjJqY2VfbmV3JTJGa2clMkZnYXJkZW4lMkZwcm90b19nYXJkZW5fd2ViYXBwX3YyLmpzJTIyJTJDJTIyZGVwRmlsZVBhdGhSZWxhdGl2ZU91dHB1dCUyMiUzQSU1QiUyMmpjZV9uZXclMkZrZyUyRnVuaV9wYXlfcHJveHklMkZ1bmlfcGF5X3Byb3h5X3YyLmpzJTIyJTVEJTdEJTJDJTIyY21kTmFtZSUyMiUzQSUyMkdhcmRlbkluZm9SZXElMjIlMkMlMjJ3bnNEaXNwYXRjaGVyJTIyJTNBdHJ1ZSU3RA=='; // 好大一个包
        //$url .= '&t_source=&t_deviceInfo=&ns_inbuf=&cmdPrefix=';
        $headers = array(
            'Host: node.kg.qq.com',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
            'Accept: application/json, text/plain, */*',
            'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Accept-Encoding: gzip, deflate, br',
            'Referer: https://kg.qq.com/',
            'Origin: https://kg.qq.com',
            'Sec-Fetch-Dest: empty',
            'Sec-Fetch-Mode: cors',
            'Sec-Fetch-Site: same-site',
            'Connection: keep-alive',
            'Cookie: ' . $this->cookie,
        );
        $rs = json_decode($this->request($url, 'GET', $headers),true); // ['data']['garden.webapp.info']['garden']['landList']
        return $rs;
    }

    // K歌花园 指定收获  多此一举...
    private function garden__webapp__timer_report($t_landId=''){
        $url = 'https://node.kg.qq.com/webapp/proxy?t_landId='.$t_landId.'&t_passback=&t_deviceInfo=&ns=proto_garden_webapp&cmd=garden.webapp.timer_report&ns_inbuf=&cmdPrefix=&mapExt=JTdCJTIyZmlsZSUyMiUzQSU3QiUyMmZpbGVQYXRoUmVsYXRpdmVPdXRwdXQlMjIlM0ElMjJqY2VfbmV3JTJGa2clMkZnYXJkZW4lMkZwcm90b19nYXJkZW5fd2ViYXBwX3YyLmpzJTIyJTJDJTIyZGVwRmlsZVBhdGhSZWxhdGl2ZU91dHB1dCUyMiUzQSU1QiUyMmpjZV9uZXclMkZrZyUyRnVuaV9wYXlfcHJveHklMkZ1bmlfcGF5X3Byb3h5X3YyLmpzJTIyJTVEJTdEJTJDJTIyY21kTmFtZSUyMiUzQSUyMlRpbWVyUmVwb3J0UmVxJTIyJTJDJTIyd25zRGlzcGF0Y2hlciUyMiUzQXRydWUlN0Q%3D&g_tk=5381&g_tk_openkey=1469557487';
        $headers = array(
            'Host: node.kg.qq.com',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
            'Accept: application/json, text/plain, */*',
            'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Accept-Encoding: gzip, deflate, br',
            'Referer: https://kg.qq.com/',
            'Origin: https://kg.qq.com',
            'Sec-Fetch-Dest: empty',
            'Sec-Fetch-Mode: cors',
            'Sec-Fetch-Site: same-site',
            'Connection: keep-alive',
            'Cookie: ' . $this->cookie,
        );
        $rs = json_decode($this->request($url, 'GET', $headers),true);
        return $rs;
    }

    // K歌花园 一键收获
    private function garden__webapp__harvest(){
        $url = 'https://node.kg.qq.com/webapp/proxy?t_uid='.$this->uid().'&t_deviceInfo=&t_oneClick=1&ns=proto_garden_webapp&cmd=garden.webapp.harvest&ns_inbuf=&cmdPrefix=&mapExt=JTdCJTIyZmlsZSUyMiUzQSU3QiUyMmZpbGVQYXRoUmVsYXRpdmVPdXRwdXQlMjIlM0ElMjJqY2VfbmV3JTJGa2clMkZnYXJkZW4lMkZwcm90b19nYXJkZW5fd2ViYXBwX3YyLmpzJTIyJTJDJTIyZGVwRmlsZVBhdGhSZWxhdGl2ZU91dHB1dCUyMiUzQSU1QiUyMmpjZV9uZXclMkZrZyUyRnVuaV9wYXlfcHJveHklMkZ1bmlfcGF5X3Byb3h5X3YyLmpzJTIyJTVEJTdEJTJDJTIyY21kTmFtZSUyMiUzQSUyMkdhcmRlbkhhcnZlc3RSZXElMjIlMkMlMjJ3bnNEaXNwYXRjaGVyJTIyJTNBdHJ1ZSU3RA%3D%3D&g_tk=5381&g_tk_openkey=1469557487';
        $headers = array(
            'Host: node.kg.qq.com',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
            'Accept: application/json, text/plain, */*',
            'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Accept-Encoding: gzip, deflate, br',
            'Referer: https://kg.qq.com/',
            'Origin: https://kg.qq.com',
            'Sec-Fetch-Dest: empty',
            'Sec-Fetch-Mode: cors',
            'Sec-Fetch-Site: same-site',
            'Connection: keep-alive',
            'Cookie: ' . $this->cookie,
        );
        $rs = json_decode($this->request($url, 'GET', $headers),true);
        return $rs;
    }

    // K歌花园 一键播种
    private function garden__webapp__plant(){
        $url = 'https://node.kg.qq.com/webapp/proxy?t_uid='.$this->uid().'&t_seedId=0&t_landId=0&t_deviceInfo=&t_oneClick=1&ns=proto_garden_webapp&cmd=garden.webapp.plant&ns_inbuf=&cmdPrefix=&mapExt=JTdCJTIyZmlsZSUyMiUzQSU3QiUyMmZpbGVQYXRoUmVsYXRpdmVPdXRwdXQlMjIlM0ElMjJqY2VfbmV3JTJGa2clMkZnYXJkZW4lMkZwcm90b19nYXJkZW5fd2ViYXBwX3YyLmpzJTIyJTJDJTIyZGVwRmlsZVBhdGhSZWxhdGl2ZU91dHB1dCUyMiUzQSU1QiUyMmpjZV9uZXclMkZrZyUyRnVuaV9wYXlfcHJveHklMkZ1bmlfcGF5X3Byb3h5X3YyLmpzJTIyJTVEJTdEJTJDJTIyY21kTmFtZSUyMiUzQSUyMkdhcmRlblBsYW50UmVxJTIyJTJDJTIyd25zRGlzcGF0Y2hlciUyMiUzQXRydWUlN0Q%3D&g_tk=5381&g_tk_openkey=1469557487';
        $headers = array(
            'Host: node.kg.qq.com',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
            'Accept: application/json, text/plain, */*',
            'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Accept-Encoding: gzip, deflate, br',
            'Referer: https://kg.qq.com/',
            'Origin: https://kg.qq.com',
            'Sec-Fetch-Dest: empty',
            'Sec-Fetch-Mode: cors',
            'Sec-Fetch-Site: same-site',
            'Connection: keep-alive',
            'Cookie: ' . $this->cookie,
        );
        $rs = json_decode($this->request($url, 'GET', $headers),true);
        return $rs;
    }

    // 阳光农场
    public function farm()
    {
        $cache = 'kg_farm_'.$this->uid(); // 计算下次操作时间
        $cache_2 = 'kg_farm_'.$this->uid().'_100'; // 当日收获 >= 100
        if($this->cache($cache_2,'au_qmkg') >= 100){return $this->cache($cache_2,'au_qmkg');}
        if($this->cache($cache,'au_qmkg')){return $this->cache($cache,'au_qmkg');}
        $cache_time = strtotime(date("Ymd")) + 86400 - time();
        $cache_time_2 = 60;
        $Tmefarm = $this->farm_farm__webapp_farm();
        if($Tmefarm['code'] == 0)
        {
            $vctFarmland = $Tmefarm['data']['farm.farm_webapp.farm']['stFarm']['vctFarmland'];
            $harvest_num = 0; // 收获次数
            $void_num = 0; // 空位数
            foreach ($vctFarmland as $k => $v) {
                if($v['uStatus'] == 1){ // 解锁
                    $s_num = $this->cache($cache_2,'au_qmkg'); // 100 次缓存
                    if($v['stCrop']['uMatureTimer'] == 0 && $v['stCrop']['strId']){  // 剩余时间为0  且已经种植
                        if($s_num < 100){
                            $this->farm_farm__webapp_harvest($v['stCrop'], $k + 1); // 收获 指定坑位
                            $harvest_num++;
                            $this->cache($cache_2,'au_qmkg',$s_num + 1,$cache_time);
                        }
                    }
                    if(!$v['stCrop']['strId']){
                        $void_num++;
                    }
                    $cache_time_2 = $cache_time_2 < $v['stCrop']['uMatureTimer'] ? $v['stCrop']['uMatureTimer'] : $cache_time_2; //确定下次执行时间
                    $this->cache($cache,'au_qmkg',$Tmefarm,$cache_time_2);
                }
            }
            if($harvest_num > 0 || $void_num > 0){
                $res = $this->farm_farm__webapp_onekey__plant(); // 一键填坑
            }
            return $vctFarmland;
        }else{
            // 失效  发送通知
            $this->send('error: '.$this->uid()." cookie Invalid !");
            $this->cache('kg_cookie_Invalid_'.$this->uid(),'au_qmkg','Invalid',3580); // 失效后 多久通知一次
            return 'error: '.$this->uid()." cookie Invalid !";
        }
    }

    // 阳光农场 获取种植信息
    public function farm_farm__webapp_farm($strPassback=''){
        $url = 'https://node.kg.qq.com/webgo/webapp/tme?cmd=farm.farm_webapp.farm';
        $post_data = '{
            "ns": "farm_webapp",
            "cmd": "farm.farm_webapp.farm",
            "data": {
              "uUid": "'.(string)$this->uid().'",
              "strRoomId": "'.$this->strRoomId.'",
              "strShowId": "'.$this->strShowId.'",
              "strPassback": "",
              "uScene": "2",
              "strUgcId": "",
              "uFromUgcDetail": "0"
            },
            "mapExt": {
              "cmdName": "FarmReq",
              "wnsDispatcher": true
            },
            "project": "kg",
            "service": "farm.farm_webapp.farm"
          }';
        $header = array(
            "Host: node.kg.qq.com",
            "Accept: application/json, text/plain, */*",
            "Sec-Fetch-Site: same-site",
            "Accept-Language: zh-CN,zh-Hans;q=0.9",
            "Accept-Encoding: gzip, deflate, br",
            "Sec-Fetch-Mode: cors",
            "Content-Type: application/json;charset=utf-8",
            "Origin: https://kg.qq.com",
            "User-Agent: Mozilla/5.0 (Linux; Android 12; 2201123C Build/V417IR; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.114 Mobile Safari/537.36 QQJSSDK/1.3 BridgeChannel/3  qua/V1_AND_KG_8.10.38_278_3001010001_X qmkege/8.10.38 bits/32 DeviceLevel/50.0 DeviceScore/724.0",
            "Referer: https://kg.qq.com/",
            "Content-Length: ".strlen($post_data),
            "Connection: keep-alive",
            "Sec-Fetch-Dest: empty",
            "Cookie: ".$this->cookie
        );
        $rs = $this->request($url, 'POST', $header, $post_data);
        return json_decode($rs,1);
    }

    // 阳光农场 收获
    private function farm_farm__webapp_harvest($cropInfo,$uFarmlandId){
        $url = 'https://node.kg.qq.com/webgo/webapp/tme?cmd=farm.farm_webapp.harvest';
        $post_data = array(
            "ns" => "farm_webapp",
            "cmd" => "farm.farm_webapp.harvest",
            "data" => array(
                "strRoomId" => $this->strRoomId,
                "strShowId" => $this->strShowId,
                "uFarmlandId" => $uFarmlandId,
                "cropInfo" => array(
                    "strAnimationResource" => "https://kg.qq.com/gtimg/music/common/upload/image/pineapple.json",
                    "strGrowImg" => "",
                    "strId" => "2_1688436675",
                    "strLotteryId" => "20000177",
                    "strName" => "菠萝",
                    "strRipeImg" => "",
                    "uGoldCoin" => "620",
                    "uGrowthValue" => "420",
                    "uMatureDuration" => "1800",
                    "uMatureTimer" => "0",
                    "uNeedFertilizer" => "200",
                    "uPlantTime" => "1688436675",
                    "uSeedId" => "12",
                    "uStatus" => "2",
                    "uSteal" => "0",
                    "uType" => "10"
                )
            ),
            "mapExt" => array(
                "cmdName" => "HarvestReq",
                "wnsDispatcher" => true
            ),
            "project" => "kg",
            "service" => "farm.farm_webapp.harvest",
        );

        // 数据包部分类型转换  pack error, interface conversion: interface {} is float64, not uint32
        $cropInfo['uGoldCoin'] = (string)$cropInfo['uGoldCoin'];
        $cropInfo['uGrowthValue'] = (string)$cropInfo['uGrowthValue'];
        $cropInfo['uMatureDuration'] = (string)$cropInfo['uMatureDuration'];
        $cropInfo['uMatureTimer'] = (string)$cropInfo['uMatureTimer'];
        $cropInfo['uNeedFertilizer'] = (string)$cropInfo['uNeedFertilizer'];
        $cropInfo['uPlantTime'] = (string)$cropInfo['uPlantTime'];
        $cropInfo['uSeedId'] = (string)$cropInfo['uSeedId'];
        $cropInfo['uStatus'] = (string)$cropInfo['uStatus'];
        $cropInfo['uSteal'] = (string)$cropInfo['uSteal'];
        $cropInfo['uType'] = (string)$cropInfo['uType'];
        $post_data['data']['uFarmlandId'] = (string)$post_data['data']['uFarmlandId'];

        $post_data['data']['cropInfo'] = $cropInfo; // 替换数据
        $header = array(
            "Host: node.kg.qq.com",
            "Accept: application/json, text/plain, */*",
            "Sec-Fetch-Site: same-site",
            "Accept-Language: zh-CN,zh-Hans;q=0.9",
            "Accept-Encoding: gzip, deflate, br",
            "Sec-Fetch-Mode: cors",
            "Content-Type: application/json;charset=utf-8",
            "Origin: https://kg.qq.com",
            "User-Agent: Mozilla/5.0 (Linux; Android 12; 2201123C Build/V417IR; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.114 Mobile Safari/537.36 QQJSSDK/1.3 BridgeChannel/3  qua/V1_AND_KG_8.10.38_278_3001010001_X qmkege/8.10.38 bits/32 DeviceLevel/50.0 DeviceScore/724.0",
            "Referer: https://kg.qq.com/",
            "Content-Length: ".strlen(json_encode($post_data)),
            "Connection: keep-alive",
            "Sec-Fetch-Dest: empty",
            "Cookie: " . $this->cookie,
        );
        $rs = $this->request($url,'POST',$header,json_encode($post_data));
        return json_decode($rs,1);
    }

    // 阳光农场 一键播种
    private function farm_farm__webapp_onekey__plant(){
        $url = 'https://node.kg.qq.com/webgo/webapp/tme?cmd=farm.farm_webapp.onekey_plant';
        $post_data = array(
            "ns" => "farm_webapp",
            "cmd" => "farm.farm_webapp.onekey_plant",
            "data" => array(
                "strRoomId" => $this->strRoomId,
                "strShowId" => $this->strShowId,
            ),
            "mapExt" => array(
                "cmdName" => "OnekeyPlantReq",
                "wnsDispatcher" => true
            ),
            "project" => "kg",
            "service" => "farm.farm_webapp.onekey_plant"
        );
        $header = array(
            "Host: node.kg.qq.com",
            "Accept: application/json, text/plain, */*",
            "Sec-Fetch-Site: same-site",
            "Accept-Language: zh-CN,zh-Hans;q=0.9",
            "Accept-Encoding: gzip, deflate, br",
            "Sec-Fetch-Mode: cors",
            "Content-Type: application/json;charset=utf-8",
            "Origin: https://kg.qq.com",
            "User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 QQJSSDK/1.0.0 qua/V1_IPH_KG_8.10.151_278_APP_A qmkege/8.10.151 GDTMobSDK/4.550.1  WKWebView model/iPhone14,5",
            "Referer: https://kg.qq.com/",
            "Content-Length: " . strlen(json_encode($post_data)),
            "Connection: keep-alive",
            "Sec-Fetch-Dest: empty",
            "Cookie: " . $this->cookie,
        );
        $rs = $this->request($url,'POST',$header,json_encode($post_data));
        return json_decode($rs,1);
    }

    // 歌房小镇 加入歌房
    private function social_ktv__member_webapp__appy_be_member(){
        $cache = 'kg_appy_be_member_' . $this->uid() . '_' . $this->strRoomId;
        if($this->cache($cache,'au_qmkg')){return $this->cache($cache,'au_qmkg');}
        $url = 'https://node.kg.qq.com/webgo/webapp/tme?cmd=social_ktv.member_webapp.appy_be_member';
        $post_data = '
        {
            "ns": "proto_social_ktv_member",
            "cmd": "social_ktv.member_webapp.appy_be_member",
            "data": {
                "strRoomId": "'.$this->strRoomId.'",
                "strShowId": "'.$this->strShowId.'"
            },
            "mapExt": {
                "file": {
                    "filePathRelativeOutput": "jce_new/kg/social_ktv/proto_social_ktv_member_v2.js",
                    "depFilePathRelativeOutput": ["jce_new/kg/social_ktv/proto_social_ktv_v2.js", "jce_new/kg/social_ktv/proto_social_ktv_room_v2.js", "jce_new/kg/ktv_room_compete/proto_ktv_room_compete_v2.js", "jce_new/kg/ktv_sing_order/proto_ktv_singer_v2.js", "jce_new/kg/unified_ktv/proto_unified_ktv_talent_v2.js", "jce_new/kg/room/proto_room_id_v2.js", "jce_new/kg/room/proto_room_heatcard_v2.js"]
                },
                "cmdName": "SocialKtvApplyBeMemberReq",
                "wnsDispatcher": true
            },
            "project": "kg",
            "service": "social_ktv.member_webapp.appy_be_member"
        }';
        $header = array(
            "accept: application/json, text/plain, */*",
            "accept-encoding: gzip, deflate, br",
            "accept-language: zh-CN,zh;q=0.9",
            "content-length: " . strlen($post_data),
            "content-type: application/json;charset=UTF-8",
            "cookie: $this->cookie",
            "origin: https://kg.qq.com",
            "referer: https://kg.qq.com/minigame/ktvFarm/index.html?_hwv=1&_hwvbg=00000000&_hwvhg=90&roomType=3&sourceType=1&showId='.$this->strShowId.'&roomId='.$this->strRoomId.'&anchorId='.$this->anchorId.'&_wv=1",
            "user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36",
        );
        $res = json_decode($this->request($url,'POST',$header,$post_data),1);
        if($res['code'] == 0){
            $this->cache($cache,'au_qmkg','已加入 >>' . $this->strRoomId, 86400 * 1000);
            return true;
        }
        return $res;
    }

    // 歌房小镇
    public function ktv_small_town(){
        $cache = 'kg_ktv_small_town_' . $this->uid() . '_' . $this->strRoomId;
        $cache_2 = 'kg_ktv_small_town_'.$this->uid().'_30000'; // 当日收益 >= 30000
        /* if($this->cache($cache,'au_qmkg')){
            return array(
                '当前坑位' => $this->cache($cache,'au_qmkg'),
                '今日收益' => $this->cache($cache_2,'au_qmkg'),
            );
        } */
        $cache_2_time = strtotime(date("Ymd")) + 86400 - time();
        $enter_user_room_farm = $this->ktv_small_town__farm_webapp__enter_user_room_farm();
        if($enter_user_room_farm['code'] == 0) {
            $vecFarmland = $enter_user_room_farm['data']['ktv_small_town.farm_webapp.enter_user_room_farm']['vecFarmland'];
            $cron_ktv_small_town = 2400;
            foreach ($vecFarmland as $k => $v) {
                if($v['bOpen'] == 'true'){ // 解锁
                    $uPlantTime = $v['stCropInfo']['uPlantTime']; // 播种时间
                    $uRemainingTime = $v['stCropInfo']['uRemainingTime']; // 剩余需要活跃的时间
                    if($uPlantTime > 0 && $uRemainingTime == 0) { // 成熟 = 收货 + 下单 + 播种
                        $this->ktv_small_town__farm_webapp__gather($k,$uPlantTime);
                        $this->cache($cache_2,'au_qmkg',$this->cache($cache_2,'au_qmkg') + 900, $cache_2_time);
                        $OrderId = $this->ktv_small_town__farm_webapp__storehouse_place_order();
                        $strOrderId = $OrderId['data']['ktv_small_town.farm_webapp.storehouse_place_order']['strOrderId'];
                        $rs = $this->ktv_small_town__farm_webapp__planting($k,$strOrderId); // 背包必须有红玫瑰种子
                    }elseif($uRemainingTime == 0 && $uPlantTime == 0){ // 空位
                        $OrderId = $this->ktv_small_town__farm_webapp__storehouse_place_order();
                        $strOrderId = $OrderId['data']['ktv_small_town.farm_webapp.storehouse_place_order']['strOrderId'];
                        $rs = $this->ktv_small_town__farm_webapp__planting($k,$strOrderId); // 背包必须的有红玫瑰种子
                    }
                    $cron_ktv_small_town = $cron_ktv_small_town > $uRemainingTime ? $uRemainingTime : $cron_ktv_small_town;
                }
            }
            $this->cache($cache,'au_qmkg', $vecFarmland, $cron_ktv_small_town);
            return $vecFarmland;
        }
        return '获取失败';
    }

    // 歌房小镇 种植信息
    private function ktv_small_town__farm_webapp__enter_user_room_farm(){
        $url = 'https://node.kg.qq.com/webgo/webapp/tme?cmd=ktv_small_town.farm_webapp.enter_user_room_farm';
        $post_data = '{
            "ns": "proto_ktv_small_town",
            "cmd": "ktv_small_town.farm_webapp.enter_user_room_farm",
            "data": {
                "strRoomId": "'.$this->strRoomId.'"
            },
            "mapExt": {
                "file": {
                    "filePathRelativeOutput": "jce_new/kg/ktv_small_town/proto_ktv_small_town_webapp_v2.js",
                    "depFilePathRelativeOutput": ["jce_new/kg/new_task/new_task_v2.js"]
                },
                "cmdName": "EnterUserRoomFarmReq",
                "wnsDispatcher": true
            },
            "project": "kg",
            "service": "ktv_small_town.farm_webapp.enter_user_room_farm"
        }';
        $headers = array(
            'Host: node.kg.qq.com',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
            'Accept: application/json, text/plain, */*',
            'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Accept-Encoding: gzip, deflate, br',
            'Content-Type: application/json;charset=utf-8',
            'Content-Length: ' . strlen($post_data),
            'Referer: https://kg.qq.com/',
            'Origin: https://kg.qq.com',
            'Sec-Fetch-Dest: empty',
            'Sec-Fetch-Mode: cors',
            'Sec-Fetch-Site: same-site',
            'Connection: keep-alive',
            'Cookie: ' . $this->cookie,
        );
        $rs = json_decode($this->request($url, 'POST', $headers, $post_data),true);
        return $rs;
    }

    // 歌房小镇 背包
    private function ktv_small_town__farm_webapp__get_user_storehouse(){
        $url = 'https://node.kg.qq.com/webgo/webapp/tme?cmd=ktv_small_town.farm_webapp.get_user_storehouse';
        $post_data = '{
            "ns": "proto_ktv_small_town",
            "cmd": "ktv_small_town.farm_webapp.get_user_storehouse",
            "data": {
                "strRoomId": "'.$this->strRoomId.'"
            },
            "mapExt": {
                "file": {
                    "filePathRelativeOutput": "jce_new/kg/ktv_small_town/proto_ktv_small_town_webapp_v2.js",
                    "depFilePathRelativeOutput": ["jce_new/kg/new_task/new_task_v2.js"]
                },
                "cmdName": "GetUserStorehouseReq",
                "wnsDispatcher": true
            },
            "project": "kg",
            "service": "ktv_small_town.farm_webapp.get_user_storehouse"
        }';
        $post_data = str_replace(' ','',$post_data);
        $headers = array(
            'Host: node.kg.qq.com',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
            'Accept: application/json, text/plain, */*',
            'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Accept-Encoding: gzip, deflate, br',
            'Content-Type: application/json;charset=utf-8',
            'Content-Length: ' . strlen($post_data),
            'Referer: https://kg.qq.com/',
            'Origin: https://kg.qq.com',
            'Sec-Fetch-Dest: empty',
            'Sec-Fetch-Mode: cors',
            'Sec-Fetch-Site: same-site',
            'Connection: keep-alive',
            'Cookie: ' . $this->cookie,
        );
        $rs = json_decode($this->request($url, 'POST', $headers, $post_data),true);
        return $rs;
    }

    // 歌房小镇 每天兑换一次种子
    private function ktv_small_town__farm_webapp__exchange_place_order(){
        $cache = 'kg_exchange_place_order_' . $this->uid();
        // 检查背包
        $rs = $this->ktv_small_town__farm_webapp__get_user_storehouse();
        $uNum = 0;
        if($rs['code'] == 0){
            $vecSeedInfoItem = $rs['data']['ktv_small_town.farm_webapp.get_user_storehouse']['vecSeedInfoItem'];
            if($vecSeedInfoItem){
                foreach ($vecSeedInfoItem as $key => $value) {
                    $value['stSeedInfo']['iId'] == 10 ? $uNum = $value['uNum'] : '';
                }
            }
            if($uNum < 35){
                // 检查资产
                $rs = $this->ktv_small_town__farm_webapp__enter_user_room_farm();
                $uGold = $rs['code'] == 0 ? $rs['data']['ktv_small_town.farm_webapp.enter_user_room_farm']['uGold'] : 0;
                $num = $uGold > 0 ? floor($uGold / 520) : 0;
                $au_num = $num > 35 ? 35 : $num;
                $url = 'https://node.kg.qq.com/webgo/webapp/tme?cmd=ktv_small_town.farm_webapp.exchange_place_order';
                $post_data = '
                {
                    "ns": "proto_ktv_small_town",
                    "cmd": "ktv_small_town.farm_webapp.exchange_place_order",
                    "data": {
                        "strRoomId": "' . $this->strRoomId . '",
                        "iWelfareId": "26",
                        "iNum": "' . $au_num . '"
                    },
                    "mapExt": {
                        "file": {
                            "filePathRelativeOutput": "jce_new/kg/ktv_small_town/proto_ktv_small_town_webapp_v2.js",
                            "depFilePathRelativeOutput": ["jce_new/kg/new_task/new_task_v2.js"]
                        },
                        "cmdName": "ExchangePlaceOrderReq",
                        "wnsDispatcher": true
                    },
                    "project": "kg",
                    "service": "ktv_small_town.farm_webapp.exchange_place_order"
                }';
                $header = array(
                    "accept: application/json, text/plain, */*",
                    "accept-encoding: gzip, deflate, br",
                    "accept-language: zh-CN,zh;q=0.9",
                    "content-length: " . strlen($post_data),
                    "content-type: application/json;charset=UTF-8",
                    "cookie: " . $this->cookie,
                    "origin: https://kg.qq.com",
                    "referer: https://kg.qq.com/minigame/ktvFarm/index.html?_hwv=1&_hwvbg=00000000&_hwvhg=90&roomType=3&sourceType=1&showId=' . $this->strShowId . '&roomId=' . $this->strRoomId . '&anchorId=' . $this->anchorId . '&_wv=1",
                    "user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Mobile Safari/537.36",
                );
                $res = json_decode($this->request($url,'POST',$header,$post_data),1);
                //return $res; // 震惊  竟然只是下了个单
                if($res['code'] == 0){
                    sleep(1); $strOrderId = $res['data']['ktv_small_town.farm_webapp.exchange_place_order']['strOrderId'];
                    $url = 'https://node.kg.qq.com/webgo/webapp/tme?cmd=ktv_small_town.farm_webapp.exchange_pay';
                    $post_data = '
                    {
                        "ns": "proto_ktv_small_town",
                        "cmd": "ktv_small_town.farm_webapp.exchange_pay",
                        "data": {
                            "strOrderId": "' . $strOrderId . '"
                        },
                        "mapExt": {
                            "file": {
                                "filePathRelativeOutput": "jce_new/kg/ktv_small_town/proto_ktv_small_town_webapp_v2.js",
                                "depFilePathRelativeOutput": ["jce_new/kg/new_task/new_task_v2.js"]
                            },
                            "cmdName": "ExchangePayReq",
                            "wnsDispatcher": true
                        },
                        "project": "kg",
                        "service": "ktv_small_town.farm_webapp.exchange_pay"
                    }
                    ';
                    $header['3'] = "content-length: " . strlen($post_data);
                    $res = json_decode($this->request($url,'POST',$header,$post_data),1);
                    if($res['code'] == 0){
                        $this->cache($cache,'au_qmkg','今日已经兑换,剩余:' . ($uNum + $au_num), strtotime(date('Y-m-d')) + 86400 - time());
                        return '今日已经兑换,剩余:' . ($uNum + $au_num);
                    }
                    return $res;
                }
                return $res;
            }else{
                $this->cache($cache,'au_qmkg','今日无需兑换,剩余:' . $uNum, strtotime(date('Y-m-d')) + 86400 - time());
                return '今日无需兑换,剩余:' . $uNum;
            }
        }
    }

    // 歌房小镇 下单获取订单号
    private function ktv_small_town__farm_webapp__storehouse_place_order(){
        $url = 'https://node.kg.qq.com/webgo/webapp/tme?cmd=ktv_small_town.farm_webapp.storehouse_place_order';
        $post_data = '{
            "ns": "proto_ktv_small_town",
            "cmd": "ktv_small_town.farm_webapp.storehouse_place_order",
            "data": {
                "strRoomId": "'.$this->strRoomId.'",
                "iId": "10",
                "uNum": "1" 
            },
            "mapExt": {
                "file": {
                    "filePathRelativeOutput": "jce_new/kg/ktv_small_town/proto_ktv_small_town_webapp_v2.js",
                    "depFilePathRelativeOutput": ["jce_new/kg/new_task/new_task_v2.js"]
                },
                "cmdName": "StorehousePlaceOrderReq",
                "wnsDispatcher": true
            },
            "project": "kg",
            "service": "ktv_small_town.farm_webapp.storehouse_place_order"
        }';
        $post_data = str_replace(' ','',$post_data);
        $headers = array(
            'Host: node.kg.qq.com',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
            'Accept: application/json, text/plain, */*',
            'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Accept-Encoding: gzip, deflate, br',
            'Content-Type: application/json;charset=utf-8',
            'Content-Length: ' . strlen($post_data),
            'Referer: https://kg.qq.com/',
            'Origin: https://kg.qq.com',
            'Sec-Fetch-Dest: empty',
            'Sec-Fetch-Mode: cors',
            'Sec-Fetch-Site: same-site',
            'Connection: keep-alive',
            'Cookie: ' . $this->cookie,
        );
        $rs = json_decode($this->request($url, 'POST', $headers, $post_data),true);
        return $rs;
    }

    // 歌房小镇 种植 需要先下单 (位置+订单号)
    private function ktv_small_town__farm_webapp__planting($iCropIndex='0', $strOrderId=''){
        $url = 'https://node.kg.qq.com/webgo/webapp/tme?cmd=ktv_small_town.farm_webapp.planting';
        $post_data = '{
            "ns": "proto_ktv_small_town",
            "cmd": "ktv_small_town.farm_webapp.planting",
            "data": {
                "strRoomId": "'.$this->strRoomId.'",
                "iCropIndex": "'.$iCropIndex.'",
                "iSeedId": "10",
                "strOrderId": "'.$strOrderId.'"
            },
            "mapExt": {
                "file": {
                    "filePathRelativeOutput": "jce_new/kg/ktv_small_town/proto_ktv_small_town_webapp_v2.js",
                    "depFilePathRelativeOutput": ["jce_new/kg/new_task/new_task_v2.js"]
                },
                "cmdName": "PlantingReq",
                "wnsDispatcher": true
            },
            "project": "kg",
            "service": "ktv_small_town.farm_webapp.planting"
        }';
        $post_data = str_replace(' ','',$post_data);
        $headers = array(
            'Host: node.kg.qq.com',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
            'Accept: application/json, text/plain, */*',
            'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Accept-Encoding: gzip, deflate, br',
            'Content-Type: application/json;charset=utf-8',
            'Content-Length: ' . strlen($post_data),
            'Referer: https://kg.qq.com/',
            'Origin: https://kg.qq.com',
            'Sec-Fetch-Dest: empty',
            'Sec-Fetch-Mode: cors',
            'Sec-Fetch-Site: same-site',
            'Connection: keep-alive',
            'Cookie: ' . $this->cookie,
        );
        $rs = json_decode($this->request($url, 'POST', $headers, $post_data),true);
        return $rs;
    }

    // 歌房小镇 收获
    private function ktv_small_town__farm_webapp__gather($iCropIndex='0',$uPlantTime=''){
        $url = 'https://node.kg.qq.com/webgo/webapp/tme?cmd=ktv_small_town.farm_webapp.gather';
        $post_data = '{
            "ns": "proto_ktv_small_town",
            "cmd": "ktv_small_town.farm_webapp.gather",
            "data": {
                "strRoomId": "'.$this->strRoomId.'",
                "iCropIndex": "'.$iCropIndex.'",
                "iSeedId": "10",
                "uPlantTime": "'.$uPlantTime.'"
            },
            "mapExt": {
                "file": {
                    "filePathRelativeOutput": "jce_new/kg/ktv_small_town/proto_ktv_small_town_webapp_v2.js",
                    "depFilePathRelativeOutput": ["jce_new/kg/new_task/new_task_v2.js"]
                },
                "cmdName": "GatherReq",
                "wnsDispatcher": true
            },
            "project": "kg",
            "service": "ktv_small_town.farm_webapp.gather"
        }';
        $post_data = str_replace(' ','',$post_data);
        $headers = array(
            'Host: node.kg.qq.com',
            'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0',
            'Accept: application/json, text/plain, */*',
            'Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
            'Accept-Encoding: gzip, deflate, br',
            'Content-Type: application/json;charset=utf-8',
            'Content-Length: ' . strlen($post_data),
            'Referer: https://kg.qq.com/',
            'Origin: https://kg.qq.com',
            'Sec-Fetch-Dest: empty',
            'Sec-Fetch-Mode: cors',
            'Sec-Fetch-Site: same-site',
            'Connection: keep-alive',
            'Cookie: ' . $this->cookie,
        );
        $rs = json_decode($this->request($url, 'POST', $headers, $post_data),true);
        return $rs; // 无所谓返回结果
    }

    // 获取 uid  
    private function uid(){
        $cookie = explode("; ", $this->cookie); $cookie_array = array();
        foreach ($cookie as $key => $value) {
            $va = explode("=", $value);
            $cookie_array[$va[0]] = $va[1];
        }
        if(!isset($cookie_array['uid'])){exit("cookie is invalid");}
        return $cookie_array['uid'];
    }

    // 发送通知
    private function send($message){
        $mess = array(
            'msgtype' => 'text',
            'text' => array(
                'content' => $message,
            ),
        );
        $result = $this->request($this->cwxrobot,"POST",['Content-Type: application/json'],json_encode($mess));
        return $result;
    }

    private function cache($name, $path='', $value ='', $expires_in='')
    {
        $cache_dir = __DIR__.'/../../runtime/au_cache/';
        if(!is_dir($cache_dir)){mkdir($cache_dir);}
        $cache_path = $path == '' ? $cache_dir : $cache_dir . $path . '/';
        if(!is_dir($cache_path)){mkdir($cache_path);}
        $key = $name; //$key = md5($name);
        $cache_file = $cache_path . $key . '.txt';
        if($value === '' && $expires_in === ''){
            if(is_file($cache_file)){
                $cache = unserialize(file_get_contents($cache_file));
                if($cache['expires_in'] > time()){
                    return $cache['data'];
                }else{
                    unlink($cache_file);
                }
            }
            return false;
        }elseif($value != '' && $value != null){
            $cache = array('data' => $value, 'expires_in' => time() + $expires_in);
            file_put_contents($cache_file, serialize($cache));
        }elseif($value == null){
            is_file($cache_file) ? unlink($cache_file) : '';
        }
    }

    private function request($Url, $Method="GET", $Header='', $Data='')
    {
        $Ch = curl_init();
        $Header = $Header ? $Header : array("Content-Type:application/json;charset=utf-8;","Accept:application/json","charset=utf-8");
        $Data = is_array($Data) ? json_encode($Data) : $Data;
        curl_setopt($Ch, CURLOPT_URL, $Url);
        curl_setopt($Ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($Ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        if($Method == "GET"){
            curl_setopt($Ch, CURLOPT_CUSTOMREQUEST,"GET");
            curl_setopt($Ch, CURLOPT_POST, false);
            curl_setopt($Ch, CURLOPT_POSTFIELDS, $Data);
        }
        if($Method == "POST"){
            curl_setopt($Ch, CURLOPT_CUSTOMREQUEST,"POST");
            curl_setopt($Ch, CURLOPT_POST, true);
            curl_setopt($Ch, CURLOPT_POSTFIELDS, $Data);
        }
        if($Method == "PUT"){
            curl_setopt($Ch, CURLOPT_CUSTOMREQUEST, "PUT");
            curl_setopt($Ch, CURLOPT_POSTFIELDS, $Data);
        }
        if($Method == "DELETE"){
            curl_setopt($Ch, CURLOPT_CUSTOMREQUEST, "DELETE");
            curl_setopt($Ch, CURLOPT_POSTFIELDS, $Data);
        }
        if($Method == "PATCH"){
            curl_setopt($Ch, CURLOPT_CUSTOMREQUEST, "PATCH");
            curl_setopt($Ch, CURLOPT_POSTFIELDS, $Data);
        }
        curl_setopt($Ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($Ch, CURLOPT_HTTPHEADER, $Header);
        curl_setopt($Ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($Ch, CURLOPT_ENCODING, 'gzip');
        $Output = curl_exec($Ch);
        curl_close($Ch);
        return $Output;
    }

}
?>

免费评分

参与人数 6吾爱币 +11 热心值 +6 收起 理由
坚强的阿飘 + 1 + 1 谢谢@Thanks!
junjia215 + 1 + 1 用心讨论,共获提升!
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
wojaiyh + 1 谢谢@Thanks!
supercilious + 1 + 1 用心讨论,共获提升!
勤快的懒虫 + 1 + 1 服务器到期了用不了,谢谢!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

wzyl 发表于 2023-9-9 18:19
大佬厉害
wushengli 发表于 2023-9-9 19:59
buzhidao 发表于 2023-9-9 20:04
wapj2900958 发表于 2023-9-9 20:17

虽然没有成品但还是谢谢分享!
开心长寿果 发表于 2023-9-9 20:17
看不明白,谢谢
moruye 发表于 2023-9-9 21:08
厉害厉害,刚好学习学习
GJH588 发表于 2023-9-9 21:29
这没点基础的人估计看不懂,不过挺好的
dlyuan 发表于 2023-9-9 21:36
感谢分享
fan_5034 发表于 2023-9-10 10:14
怎么运行啊
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-28 09:39

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表