可以用于检测QQ_COOKIE 是否失效 接口来源地址QQ业务开通
<?php /** * QQ_COOKIE存活期检测 * @author 晓超云博客 * @link https://blog.kit9.cn/ * @time 2022年11月03日 */ $qq='123456';//填写qq号 $skey='123456';//填写skey @带不带看你什么地方取得 安卓和网页都可以 $url = 'http://api.unipay.qq.com/v1/r/1450000172/wechat_query?cmd=7&session_id=uin&session_type=skey&openid='.$qq.'&openkey='.$skey; $Cookie = 'p_uin=o'.$qq.'; uin=o'.$qq.'; skey='.$skey; $header = ['User-Agent: Mozilla/5.0 (Linux; Android 10; HLK-AL00 Build/HONORHLK-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 Safari/537.36 V1_AND_SQ_8.4.5_1468_YYB_D QQ/8.4.5.4745 NetType/4G WebP/0.4.1 Pixel/1080 StatusBarHeight/51 SimpleUISwitch/0 QQTheme/1000 InMagicWin/0']; $data = teacher_curl($url,[ 'cookie'=>$Cookie, 'Header'=>$header ]); $json=json_decode($data,true); if ($json['ret'] == 0) { die (json_encode(['code' => 200, 'msg' => 'success', 'result'=> 'COOKIE正常'],320)); } else if ($json['ret'] == 1018) { die (json_encode(['code' => 201, 'msg' => 'failure', 'COOKIE已失效'],320)); } function teacher_curl($url, $paras = array()){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); if (@$paras['Header']) { $Header = $paras['Header']; } else { $Header[] = "Accept:*/*"; $Header[] = "Accept-Encoding:gzip,deflate,sdch"; $Header[] = "Accept-Language:zh-CN,zh;q=0.8"; $Header[] = "Connection:close"; } curl_setopt($ch, CURLOPT_HTTPHEADER, $Header); if (@$paras['ctime']) { // 连接超时 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $paras['ctime']); } else { curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); } if (@$paras['rtime']) { // 读取超时 curl_setopt($ch, CURLOPT_TIMEOUT, $paras['rtime']); } if (@$paras['post']) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $paras['post']); } if (@$paras['header']) { curl_setopt($ch, CURLOPT_HEADER, true); } if (@$paras['cookie']) { curl_setopt($ch, CURLOPT_COOKIE, $paras['cookie']); } if (@$paras['refer']) { if ($paras['refer'] == 1) { curl_setopt($ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter?g_f='); } else { curl_setopt($ch, CURLOPT_REFERER, $paras['refer']); } } if (@$paras['ua']) { curl_setopt($ch, CURLOPT_USERAGENT, $paras['ua']); } else { curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"); } if (@$paras['nobody']) { curl_setopt($ch, CURLOPT_NOBODY, 1); } curl_setopt($ch, CURLOPT_ENCODING, "gzip"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if (@$paras['GetCookie']) { curl_setopt($ch, CURLOPT_HEADER, 1); $result = curl_exec($ch); preg_match_all("/Set-Cookie: (.*?);/m", $result, $matches); $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($result, 0, $headerSize); //状态码 $body = substr($result, $headerSize); $ret = [ "Cookie" => $matches, "body" => $body, "header" => $header, 'code' => curl_getinfo($ch, CURLINFO_HTTP_CODE) ]; curl_close($ch); return $ret; } $ret = curl_exec($ch); if (@$paras['loadurl']) { $Headers = curl_getinfo($ch); $ret = $Headers['redirect_url']; } curl_close($ch); return $ret; }