php unit for performing HTTP GET and POST requests.
By : igosha
<?php
/*! This function performs a http POST query (i.e. form submission) and * returns the received response. \return FALSE Something went wrong, possibly the server refused your query or the connection to the server failed. \return The response string. */ function http_post($server /**< Server's or proxie's host name or IP.*/, $port, /**< Server's or proxie's port */ $url, /**< Should point to the URL on the server or full address if a proxy is used. */ $cookie, /**< The optional cookie string. */ $vars /**< Associative array of POST variables. Each key is the name of the variable and the value is the variable's content */ ) { $user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)";
if (!is_bool($pos)) { $ret = substr($ret, $pos); }
return $ret;
}
/** This function performs a http GET query (i.e. download a web page or file) and * returns the received response. \return FALSE Something went wrong, possibly the server refused your query or the connection to the server failed. \return The response string. */ function http_get($server, /**< Server's or proxie's host name or IP.*/ $port, /**< Server's or proxie's port */ $url, /**< Should point to the URL on the server or full address if a proxy is used. */ $cookie, /**< The optional cookie string. */ $additional_fields = "" /**< Optional string containing additional HTTP request fields, each terminated by "\r\n". */) { $user_agent = "Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)";
if (!is_bool($pos)) { $ret = substr($ret, $pos); }
return $ret; }
?>
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.