8 February 2016

SimplePie is set to 10 seconds timeout in default. So if the feed has problem with speed then you can increase the time. The exact error that I got was "cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received".

Source code viewer
  1. // Make sure SimplePie is included.
  2. require_once(dirname(__FILE__) . '/simplepie_1.3.1.php');
  3.  
  4. // Initialize SimplePie Class.
  5. $simplepie = new SimplePie();
  6.  
  7. // Prolong timeout, default was 10 and was not enough.
  8. $simplepie->set_timeout(20);
  9.  
  10. // Give rss feed url to SimplePie.
  11. $simplepie->set_feed_url($url);
  12.  
  13. // Init initializes the feed download and parsing.
  14. $simplepie->init();
  15.  
  16. // If error occurs, show it.
  17. if ($simplepie->error()) {
  18. $error = $simplepie->error();
  19. }
  20. else {
  21. print_r($simplepie->get_items());
  22. }
Programming Language: PHP