In php, XMLHttpRequest (Ajax) cannot set a custom Referer solution. Solution: Use the server as the proxy. in PHP, use my favorite most powerful CURL. below is the example code for querying Domain names on www.net.cn to copy the code as follows :? Php $ dn solution: Use the server as the proxy.
In PHP, use my favorite most powerful CURL.
The following is the instance code for querying Domain names on www.net.cn.
The code is as follows:
$ Dn = $ _ GET ['dn ']; // domain name, excluding www
$ Ex = $ _ GET ['x']; // top-level domain names, such as. com and. cn, including the top-level domain names.
// Query whether 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 = encrypt; _ utmz = 1.132220.246.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 it to Ajax
'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' // impersonate, hey
));
Curl_exec ($ ch); // returns the query result to the front end, which is processed by JS.
The supervisor uses the server as the proxy. in PHP, use my favorite most powerful CURL. The following is the code of the instance for querying Domain names on HiChina :? Php $ dn...