Problem with cURL

Hi, I am facing a strange problem with curl. I am fetching two different URLs on a single page with curl in two different functions. The 1st function returns proper data but the 2nd doesn’t return anything. If I comment out the 1st function then the 2nd one works nicely. I have pulling out my hair for over 3 hours now and I need your help…

$feed_uri = ‘’.urlencode(‘’);
$favicon = getFaviconName($feed_uri); //This will return the favicon address for the feed. Something like This function is working fine and returns the url properly.

preg_match(’/[^.]+$/’, $favicon, $matches);
$mime = ‘bmp’;
if ($matches[0] == ‘ico’) {
$mime = ‘x-icon’;
} else {
$mime = $matches[0];
header(‘Content-type: image/’.$mime);

echo renderFavicon($favicon); //This will fetch the image and then spit it out to the browser. This is not working, it just renders nothing. If I comment out the getFaviconName function call from above and directly pass the icon url then it works fine.

<?php function getFaviconName($uri) { $fv = curl_init(); curl_setopt($fv, CURLOPT_URL, $uri); curl_setopt($fv, CURLOPT_HEADER, false); curl_setopt($fv, CURLOPT_RETURNTRANSFER, true); ob_start(); $ficon = curl_exec($fv); ob_end_clean(); curl_close($fv); return $ficon; } function renderFavicon($fav) { //$favicon = ''; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $fav); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); $icon = curl_exec($ch); echo $icon; curl_close($ch); return $icon; } ?>[/code]
Sponsor our Newsletter | Privacy Policy | Terms of Service