Hey all,
I’ve got a little custom PHP code snippet that pulls a simple FB feed into a WordPress site:
The feed is in the footer area under “Updates.”
It works, but it seems to slow the site response time way down. I’m using a basic curl call to get the feed. Code is below:
$ch = curl_init('http://www.facebook.com/feeds/page.php?id=127872413892696&format=rss20');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, array('User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Safari/534.45'));
$response = curl_exec($ch);
$xml = simplexml_load_string($response) or die("XML string not loading");
$entry = $xml->channel->item;
for ($i = 0; $i < 5; $i++) {
$returnMarkup .= "<div style='padding-bottom:5px'><a href='";
$returnMarkup .= $entry[$i]->link."' target='_blank'>";
$returnMarkup .= "<span style='color: #fef675; font-weight: bold;'>".strtoupper(date("M j, Y", strtotime($entry[$i]->pubDate)))."</span> - ";
$returnMarkup .= $entry[$i]->title;
$returnMarkup .= "</a></div><br />";
}
echo $returnMarkup;
curl_close($ch);
Is this code doing anything really dumb that would cause a big lag in response time? Is there a better way to do this?
Thanks!
K