Recently, I developed a project in the company and cooperated with the client staff to Develop interfaces. The interface must receive the header information transmitted by the client staff, therefore, you cannot access this interface in the browser. Because the parameters you pass are incomplete, you recently thought of a method: simulate some data submission locally, in this case, I use the fsockopen function.
Recently, I developed a project in the company and cooperated with the client staff to Develop interfaces. The interface must receive the header information transmitted by the client staff, therefore, you cannot access this interface in the browser. Because the parameters you pass are incomplete, you recently thought of a method: simulate some data submission locally, in this case, I use the fsockopen function.
Recently, I developed a project in the company and cooperated with the client staff to Develop interfaces. The interface must receive the header information transmitted by the client staff, therefore, you cannot access this interface in the browser. Because the parameters you pass are incomplete, you recently thought of a method: simulate some data submission locally, at this time, I used the fsockopen function, which is quite good ..
Function index () {$ posturl = "XXX"; $ Did = '000000'; $ Key = md5 ($ Did. $ this-> Keym); $ ms = $ this-> require_by_socket ("Mm", "action", $ posturl, $ Did, $ Key ); // $ this-> display (); echo $ ms;} function require_by_socket ($ action, $ method, $ posturl, $ Did, $ Key) {$ fp = fsockopen ("$ posturl", 80, $ errno, $ errstr, 30); if (! $ Fp) {echo "$ errstr ($ errno)
\ N ";} else {// $ params = array ('did' => 1009, 'ver '=> '2017/123456', 'filmid' => 18 ); // $ post = http_build_query ($ params ); $ post = "did = 352110051958276 & ver = 199/22/20121222 & filmid = 18 & model = HTC & OS = and & pid = 1 & refresh = 1 "; // echo $ post; exit; $ header = "POST/service/index. php/$ action/$ method HTTP/1.1 \ r \ n "; $ header. = "Host: $ posturl \ r \ n"; $ header. = "Content-Type: application/x-www-form-urlencoded ". "\ r \ n"; $ Header. = "Content-Length :". strlen ($ post ). "\ r \ n"; $ header. = "Did: $ Did \ r \ n"; $ header. = "Key: $ Key \ r \ n"; // the header information is submitted here $ header. = "Connection: Close \ r \ n"; $ header. = $ post. "\ r \ n"; $ inheader = 1; fputs ($ fp, $ header); while (! Feof ($ fp) {$ result = fgets ($ fp, 1024 ); // only the returned data on the page is displayed when the request packet header is removed. if ($ inheader & ($ result = "\ n" | $ result = "\ r \ n" )) {$ inheader = 0;} // echo $ inheader; exit; if ($ inheader = 0) {$ info. = $ result ;}} fclose ($ fp); return $ info ;}}
Note: The above
$header .="Did:$Did\r\n";$header .="Key:$Key\r\n";
These parameters are actually the header parameter information that the developer wants. Then you can use the function to process the parameters so that you can get what you want.
We also share another method:
CURL: