Ok, so what I am looking for is somewhat similar like the code below which is very dummy and not working for some reason which I totally don't care about now (please read the question under the code!!):
$url = urldecode($_GET["link"]);
$port = (preg_match("/^https\:\/\//", $url) > 0 ? 443 : 80);
$headers = "GET / HTTP/1.1\r\n";
$headers .= "Host: $url";
$headers .= "Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.3\r\n";
$headers .= "Accept-Encoding: gzip,deflate,sdch\r\n";
$headers .= "Accept-Language: hu-HU,hu;q=0.8,en-US;q=0.6,en;q=0.4\r\n";
$headers .= "Cache-Control: no-cache\r\n";
$headers .= "Connection: keep-alive\r\n";
$headers .= "User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5\r\n\r\n";
//yea, I'm using Google Chrome's userAgent
$socket = @fsockopen($url, $port) or die("Could not connect to $url");
if ($socket) {
fwrite($socket, $headers);
while (!feof($socket)) {
echo fgets($socket, 128);
}
fclose($socket);
}
As you can see, what I am trying to achieve is to somehow fetch the html or any other output from the url give in the GET global. Again, the code is not working and I don't care, I don't need code correction, I need infos/guidance.
Now. I am not a PHP guru so the question is somewhat complex:
- what options do I have to achieve the above mentioned need?
- what do I have to take care of before/after doing that specific method?
- any dependecnies (library)?
- pros/kontras/previous experiences?
Also I am very thankful if you answer with just a bunch of links, I'm not exactly looking for a droid answer like "this is the most sacred and only way you should do!", I am more about gathering infos and options, knowledge. =)
I have no idea whether this matters or not (like for the driver for MongoDB): I am using WAMP Server currently on a Windows 7 x64 and later I plan to move it under my CentOS 6.2 webserver so please also consider these also (might have dependencies on Linux).