I am running a feed reader site, where there will be a lot of RSS around. I will have to synchronize those feeds as often as possible, so I found these two methods of doing it.
1 method : Using CURL
$weblog_name = 'MyBlog';
$weblog_url = 'http://feeds.feedburner.com/myblog';
$ping_url = 'http://ping.feedburner.com';
$request = <<<EOT
<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
<methodName>weblogUpdates.ping</methodName>
<params>
<param>
<value>
<string>$weblog_name</string>
</value>
</param>
<param>
<value>
<string>$weblog_url</string>
</value>
</param>
</params>
</methodCall>
EOT;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $ping_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt($ch, CURLOPT_POST, true );
curl_setopt($ch, CURLOPT_POSTFIELDS, trim($request));
$result = curl_exec($ch);
curl_close($ch);
Second Method : file_get_contents
file_get_contents("http://feedburner.google.com/fb/a/pingSubmit?bloglink=http://feeds.feedburner.com/myblog");
My question is which is the better and faster solution to ping at least 50 feeds at once ?
Fetching google.com using file_get_contents took (in seconds):
CURL took:
This was using the benchmark class from http://davidwalsh.name/php-timer-benchmark