SimplePie behaving differently on local vs. server |
[eluser]ericbae[/eluser]
I have a simple code, which uses SimplePie RSS parser. Code: // load rss feeds The above code works fine on my local machine. However, when I upload it to my server, it gives the following statement in the "print_r" statement. Code: [error] => A feed could not be found at http://news.google.com.au/news?pz=1&ned=us&hl=en&output=rss&q=Bible+Study Any ideas?
[eluser]Eric_WVGG[/eluser]
Is your host running PHP 5.1.3+? The current "1.3dev" release of Simplepie has higher requirements.
[eluser]jasonfx[/eluser]
Ericbae, Can I ask where you downloaded the simplepie rss library for codeigniter? I can't seem to find it on simplpie's site or their git repository. Thanks, much appreciated.
[eluser]Eric_WVGG[/eluser]
https://github.com/simplepie/simplepie/archives/master note: there is no "simplepie for codeigniter," there's just simplepie. You can write a simple wrapper library yourself or just include the library and use it directly from your controller.
[eluser]jasonfx[/eluser]
[quote author="Cowboy_X" date="1310425064"]https://github.com/simplepie/simplepie/archives/master note: there is no "simplepie for codeigniter," there's just simplepie. You can write a simple wrapper library yourself or just include the library and use it directly from your controller.[/quote] Thanks for your response. My apologies, but I'm kinda new to using libraries that are not native to codeigniter. I downloaded and extracted the files from the repository. Theres a ton of files, which ones should I drop into the libraries folder? Thanks again. I don't mean to turn your attention away from resolving your issues.
[eluser]Eric_WVGG[/eluser]
No problem, my life is kind of revolving around Simplepie and CodeIgniter at the moment. Here's a sample wrapper. Assumes you're on Codeigniter 2 "Reactor" 1. Yes, rename the folder to "simplepie" and move the entire thing into your application/libraries folder. You'll want the whole thing there, unchanged, so that you can simply dump in a replacement when a new version gets released. 2. Make a new file called libraries/feed_reader.php. Should read like this: <code><?php include_once('simplepie/SimplePieAutoloader.php'); include_once('simplepie/idn/idna_convert.class.php'); class feed_reader { function scan( $xmlUrl ){ $feed_reader = new SimplePie(); $feed_reader->set_feed_url($xmlUrl); $success = $feed_reader->init(); if(!$success) { $feed_reader->__destruct(); return false; } if($success) { $items = $feed_reader->get_items(); return $items; // or loop over them, or whatever } $feed_reader->__destruct(); } } </code> 3. From your controller...<code> $this->load->library('feed_reader'); $items = $this->feed_reader->scan('http://somesite.com/rss.xml'); </code> You might need to set write permissions for the SimplePie cache dir, or set_cache_location to a mysql database, or whatever.
[eluser]jasonfx[/eluser]
:-) That was more than I expected! Thank you so much! This'll help me get it off the ground. |
Welcome Guest, Not a member yet? Register Sign In |