php XMLHttpRequest of Ajax cannot set a custom Referer solution
- 2020-05-10 17:49:27
- OfStack
Solution: use a server as a proxy.
In PHP, use my favorite and most powerful CURL, heh heh
The following is an example code to query a domain name on the Internet
In PHP, use my favorite and most powerful CURL, heh heh
The following is an example code to query a domain name on the Internet
<?php
$dn = $_GET['dn']; // The domain name , Do not include www
$ex = $_GET['ex']; // Top-level domain names , Such as .com, .cn, Including the first one .
// Check to see if the domain name has been registered
$url = 'http://pandavip.www.net.cn/check/check_ac1.cgi';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true); // POST
curl_setopt($ch, CURLOPT_POSTFIELDS, 'domain='.$dn.$ex);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0');
curl_setopt($ch, CURLOPT_COOKIE, '__utma=1.1486902564.1322109246.1322109246.1322109246.1; __utmz=1.1322109246.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); AdSource=GOOGLE%u641C%u7D22; AdWordID=gg96011009070005; __utmc=1');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'X-Requested-With' => 'XMLHttpRequest', // Set to Ajax way
'Referer' => 'http://pandavip.www.net.cn/cgi-bin/Check.cgi?queryType=0&domain1='.$dn.'&image.x=0&image.y=0&domain='.$dn.'&big5=n&sign=2&url=www.net.cn&'.trim($ex, '.').'=yes' // An impostor , Hey hey
));
curl_exec($ch); // Returns the query results to the front end , with JS To deal with