PHP PEAR HTTP related package

xiaoxiao2021-03-06  43

HTTP in PHP PEAR HTTP related packagepear can implement HTTP operations such as remote page capture, judgment page, Socket operation, simulation authentication, commit, upload, download file, etc. related to HTTP operations, in this zero fragmentation Some of the code, used after preparation, no finishing.

HTTP_REQUEST crashes remote page sendrequest ()) {Echo $ req-> getResponsebody ();} // Second page $ req-> setMethod (http_request_method_post); // http_request_method_get $ req-> addpostdata ("foo" , "bar"); $ req-> seturl ("http://pear.php.net"); $ req-> clearpostdata (); if (! Pear :: ISERROR ($ req-> sendrequest ()))) {$ Response2 = $ req-> getResponsebody ();} else {$ response2 = "} Echo $ response2;?> // Get an identity authentication page (Authentication verification mode) SetBasicAuth (" 111 "," 111 ");

$ response = $ req-> sendrequest ();

IF (Pear :: ISERROR ($ response)) {Echo $ response-> getMessage ();} else {echo $ req-> getResponsebody ();}?> // detect if a specified URL is available

$ urls = array ("http://www.example.com/", "http://example.com/thisdoesnotexist.html");

$ REQ = & new http_request (""); Foreach ($ URLS AS $ URL) {$ Req-> Seturl ($ URL); $ REQ-> SendRequest ();

$ code = $ req-> getResponsecode (); switch ($ code) {copy 404: echo "document not found / n";

Case 200: Echo "Everything's OK / N"; BREAK;

/ * ... * /}}?>

// Download common file types are: Application / PDF Application / Zip Application / X-OCTSTREAM / / / Default TEXT / CSS IMAGE / JPEG, etc. setParams ($ Params); $ h-> send (); break; case 'arch': http_download :: Sendarchive ('foo.'] $ _get ['type'], $ _get ['what'], $ _get ['type' ]);

转载请注明原文地址:https://www.9cbs.com/read-55652.html

New Post(0)