Xmlhttprequestajax in PHP cannot set a custom Referer workaround

Source: Internet
Author: User
WORKAROUND: Use the server as the proxy.
In PHP, use my favorite of the most powerful curl, hehe
Here is the example code for querying the domain name in the million grid

Copy the Code code as follows:


$DN = $_get[' dn ']; Domain name, not including www
$ex = $_get[' ex ']; Top-level domain names, such as. com,. cn, including the front.
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=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 mode
' 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 '//Imposter, hehe
));
Curl_exec ($ch); Return the query results to the front end, using JS processing

The above describes the PHP Xmlhttprequestajax can not set a custom Referer solution, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.