Welcome to the Linux community forum and interact with 2 million technical staff to access the php function for obtaining content. The Code is as follows :? Phpfunction_open ($ url, $ data, $ cookienull, $ methodGET, $ timeout60) {$ optionsarray (); $ options [] [method] $ method; $ options
Welcome to the Linux community forum and interact with 2 million technical staff> go to the php function to get content. The Code is as follows :? Php function _ open ($ url, $ data, $ cookie = null, $ method = "GET", $ timeout = 60) {$ options = array (); $ options [''] ['method'] = $ method; $ options
Welcome to the Linux community forum and interact with 2 million technicians>
Php functions for getting content.
The Code is as follows:
Function _ open ($ url, $ data, $ cookie = null, $ method = "GET", $ timeout = 60 ){
$ Options = array ();
$ Options [''] ['method'] = $ method;
$ Options [''] ['user _ agent'] = $ _ SERVER ['_ USER_AGENT'];
$ Options [''] ['timeout'] = $ timeout;
If ($ method = "POST "):
$ Length = strlen ($ data );
//
$ Options [''] ['header'] =" Content-type: application/x-www-form-urlencoded \ r \ n ".
"Content-Length: {$ length} \ r \ n ".
"P3P: CP = \" CURa ADMa DEVa PSAo PSDo our bus uni pur int dem sta pre com nav otc noi dsp cor \ "\ r \ n ".
"Cookie: {$ cookie} \ r \ n ".
"Connection: close \ r \ n ";
$ Options [''] ['content'] = $ data;
Else:
$ Options [''] ['header'] =" Content-type: application/x-www-form-urlencoded \ r \ n ".
"P3P: CP = \" CURa ADMa DEVa PSAo PSDo our bus uni pur int dem sta pre com nav otc noi dsp cor \ "\ r \ n ".
"Cookie: {$ cookie} \ r \ n ".
"Connection: close \ r \ n ";
Endif;
$ Context = stream_context_create ($ options );
Return file_get_contents ($ url, 0, $ context );
}
Echo _ open (": // 1.php"," username = haowei "," id = 5 "," POST ");