原接口:http:/a.com/xxx?hhh=abc123456
新接口:http:/b.com/xxx?hhh=abc123456
实现效果:访问我们的新接口,会调用旧接口并传递输入的参数后,返回原接口内容。当然如果想更改接口返回的内容可以另外进行处理,这里就不演示了。
<?php function get_url_content($url){ $user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0)"; $ch = curl_init(); //curl_setopt ($ch, CURLOPT_PROXY, $proxy); curl_setopt ($ch, CURLOPT_URL, $url);//设置要访问的IP curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);//模拟用户使用的浏览器 @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1 ); // 使用自动跳转 curl_setopt ($ch, CURLOPT_TIMEOUT, 60); //设置超时时间 curl_setopt ($ch, CURLOPT_AUTOREFERER, 1 ); // 自动设置Referer curl_setopt ($ch, CURLOPT_COOKIEJAR, 'c:\cookie.txt'); curl_setopt ($ch, CURLOPT_HEADER,0); //显示返回的HEAD区域的内容 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 10); $result = curl_exec($ch); curl_close($ch); return $result; } $IP = $_GET["hhh"]; print_r(get_url_content('https://gwgp-cekvddtwkob.n.bdcloudapi.com/ip/geo/v1/district?ip='.$IP)); ?>
隐藏内容需要回复可以看见
回复
卧槽!无奈本人没文化,一句卧槽行天下!
卧槽!无奈本人没文化,一句卧槽行天下!
楼主辛苦了,谢谢楼主,楼主好人一生平安!
楼主辛苦了,谢谢楼主,楼主好人一生平安!