Home » Solved Issues

Alternative of curl method.

3 June 2010 No Comment

Posts and pages
There may be certain servers which do not allow curl options so there is a alternate option for it. We can use the following code instead of curl:

$file = fopen ($url, "r");
if (!$file) {
    echo "<p>Unable to open remote file.\n";
    exit;
}
while (!feof ($file)) {
 $line = fgets ($file, 1024);
  /* This only works if the title and its tags are on one line */
  if (preg_match ("@\<title\>(.*)\</title\>@i", $line, $out)) {
  $title = $out[1];
   break;
 }
}
fclose($file);

where $url is the url of the website

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.