大横幅1
大横幅2
到期时间:永久 到期时间:推广
小横幅3 小横幅4
  1. 当前位置:网站首页 > 技术教程

PHP腾讯域名拦截检测接口源码


  1. <?php
  2. header('Access-Control-Allow-Origin:*');
  3. header('Content-type:application/json; charset=utf-8');
  4. error_reporting(0);
  5. !empty($_GET['url']) ? $url = $_GET['url'] : exit(json_encode([
  6. 'code'=>-1,
  7. "msg"=>"请输入网址"
  8. ],JSON_UNESCAPED_UNICODE));
  9. $json = jsonp_decode(Curl_GET("https://cgi.urlsec.qq.com/index.php?m=check&a=check&callback=jQuery11.306943167371763181_15671.3944271&url={$url}&_=".msectime()));
  10. if ($json->reCode!==0){
  11. $arr=[
  12. "code"=>-1,
  13. "msg"=>$json->data,
  14. ];
  15. }else{
  16. $type = $json->data->results->whitetype;
  17. $urls = $json->data->results->url;
  18. if ($type==1 || $type==3){
  19. $arr=[
  20. "code"=>1,
  21. "msg"=>"检测成功",
  22. "url"=>$urls,
  23. "type"=>"正常"
  24. ];
  25. }else{
  26. $arr=[
  27. "code"=>1,
  28. "msg"=>"检测成功",
  29. "url"=>$urls,
  30. "type"=>"拦截"
  31. ];
  32. }
  33. }
  34. exit(json_encode($arr,JSON_UNESCAPED_UNICODE));
  35. /**
  36. * @return string
  37. * Curl GET
  38. */
  39. function Curl_GET($url){
  40. $ch = curl_init(); // Curl 初始化
  41. $header = [
  42. 'X-FORWARDED-FOR:218.91.92.84',
  43. 'CLIENT-IP:218.91.92.84',
  44. 'Cookie: pgv_pvi=9897416704; RK=WI7w5+CMZn; ptcz=e383433090496e1f60381fd68733196426868ba1876249a6736bcc4a3eb8ec72; pgv_pvid=455855220; cid=89410138-a33a-4ea9-98f2-4436da89d67d; _tfpdata=yBRknXvS8CfrED0zD85NZfxCPzT5SW8KEY03rIziZmu9ogk9y%2B5%2FU4QrJBbfqfuVqr%2F6vw8nSWfqHR3fu2Jc0TPvszwmrMwXEdN%2B8bKKfHwNCcL%2F2%2Fbhmiu%2B%2F4IgK1DX'
  45. ];
  46. curl_setopt($ch, CURLOPT_URL, $url); // 设置 Curl 目标
  47. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Curl 请求有返回的值
  48. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); // 设置抓取超时时间
  49. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // 跟踪重定向
  50. curl_setopt($ch, CURLOPT_ENCODING, ""); // 设置编码
  51. curl_setopt($ch, CURLOPT_REFERER, $url); // 伪造来源网址
  52. curl_setopt($ch, CURLOPT_HTTPHEADER, $header); //伪造IP
  53. 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"); // 伪造ua
  54. curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); // 取消gzip压缩
  55. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts
  56. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  57. $content = curl_exec($ch);
  58. curl_close($ch); // 结束 Curl
  59. return $content; // 函数返回内容
  60. }
  61. /**
  62. * 返回当前毫秒
  63. */
  64. function msectime() {
  65. list($msec, $sec) = explode(' ', microtime());
  66. return (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
  67. }
  68. /**
  69. * @param $jsonp
  70. * @param bool $assoc
  71. * @return mixed
  72. * jsonp转对象
  73. */
  74. function jsonp_decode($jsonp, $assoc = false)
  75. {
  76. $jsonp = trim($jsonp);
  77. if(isset($jsonp[0]) && $jsonp[0] !== '[' && $jsonp[0] !== '{') {
  78. $begin = strpos($jsonp, '(');
  79. if(false !== $begin)
  80. {
  81. $end = strrpos($jsonp, ')');
  82. if(false !== $end)
  83. {
  84. $jsonp = substr($jsonp, $begin + 1, $end - $begin - 1);
  85. }
  86. }
  87. }
  88. return json_decode($jsonp, $assoc);
  89. }

本文最后更新于2019-9-13,已超过 3个月没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!
获取更多资讯请加入交流群

    协助本站SEO优化一下,谢谢!
    关键词不能为空
版权说明

本文地址:http://www.kirinbk.cn/post-176.html
免责声明:本站文章仅用于科普及教育用途,远离犯罪!

发表评论

联系我们

在线咨询:点击这里给我发消息

QQ交流群:KirinBlog

工作日:8:00-23:00,节假日休息

扫码关注