File_get_contents Post Data

Source: Internet
Author: User

//Header headers for default impersonation    Private function_defaultheader () {$header= "user-agent:mozilla/5.0 (Windows; U Windows NT 5.1; ZH-CN; rv:1.9.2.12) gecko/20101026 firefox/3.6.12\r\n "; $header. = "accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"; $header. = "accept-language:zh-cn,zh;q=0.5\r\n"; $header. = "accept-charset:gb2312,utf-8;q=0.7,*;q=0.7\r\n"; return $header; }
Private functionPost$url,$post _data=Array(),$timeout=5,$header="") {        $header=Empty($header) ? Self::_default_header ():$header; $post _string=Http_build_query($post _data); $header. = "Content-length:".strlen($post _string); $opts=Array(            ' http ' =Array(                ' Protocol_version ' = ' 1.0 ',//HTTP protocol version (default to http1.0 if php5.2 is not specified)' Method ' = ' POST ',//How to get' Timeout ' =$timeout,//Timeout period' Header ' =$header, ' content ' =$post _string)        ); $context=stream_context_create($opts); //to resolve an interface timeout        $cnt=0;  while($cnt< 3 && ($str[Email protected]file_get_contents($url,false,$context))===FALSE)            $cnt++; return $str; }

File_get_contents Post Data

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.