Method 1: Curl
//Check for curl before doing anything
if(function_exists(“curl_init”)){
//Initialize curl
$curl_feed = curl_init(“http://netw0rk.blogspot.com/”);
//Curl Options
curl_setopt($curl_feed, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_feed, CURLOPT_HEADER, 0);
//Store our data
$data = curl_exec($curl_feed);
//Close curl
curl_close($curl_feed);
}
Method 2: fopen
//Initialize fopen
$fopen_feed = @fopen(“http://netw0rk.blogspot.com/”, “r”);
//Make sure fopen was successfull
if ($fopen_feed) {
//Store our data
$data = “”;
while (!feof($fopen_feed)) {
$data .= fread($fopen_feed, 8192);
}
}
//Close fopen
fclose($fopen_feed);
Method 3: fsockopen
//Initialize fsockopen
$fsockopen_feed = @fsockopen(“http://netw0rk.blogspot.com/”, 80, $errno, $errstr, 30);
if ($fsockopen_feed){
//Create our headers for the request
$headers = “GET http://netw0rk.blogspot.com/ HTTP/1.1\r\n”;
$headers .= “Host: netw0rk.blogspot.com”\r\n”;
$headers .= “Connection: Close\r\n\r\n”;
fwrite($fsockopen_feed, $headers);
//Store our data
$data = “”;
while (!feof($fsockopen_feed)){
$data .= fgets($fp, 128);
}
//Close fsockopen
fclose($fsockopen_feed);
// Strip the header information
$data = explode(“\\r\\”, $data);
$data = $data[1];
}
4 years ago
No comments:
Post a Comment