about 1 year ago - 2 comments
For the past few years I’ve been maintaining a PHP package called XML_Feed_Parser. It’s part of PEAR and attempts to offer a unified API for handling RSS and Atom feeds in your PHP code, a little inspired by projects like the universal feed parser. Its parsing and API are pretty comprehensive, but lately I’ve been More >
about 1 year ago - 1 comment
As I’ve mentioned here before, when working on web applications built with PHP, whether custom-rolled or drupal-driven, I often find myself missing various tools from the ruby kit. I’ve talked before about using capistrano with non-ruby code, but lately it’s been rspec and its stories that I’ve been craving.
I’m aware of PHPSpec and have played More >
about 1 year ago - Comments Off
Last autumn’s release of Pro Drupal Development was a significant moment in the history of the popular CMS, providing for the first time a relatively comprehensive guide for those wanting to do more than simply manage and skin a drupal site. A number of books have followed it but few have delved as deeply or More >
about 1 year ago - 1 comment
One of the numerous projects I’ve been juggling over the past few months has been a redesign of the Greenbelt Festival website. That redesign went live late last night.
Working from Wilf’s designs I initially built new HTML and CSS templates and began to establish some rules for how we’d handle the new image management requirements More >
about 2 years ago - Comments Off
With PHP 5.3 looking very close to release, bringing with it significant changes such as namespaces, this is an awkward time to release a PHP book of any generality. Within a few months it will be clearer how well the new features are taking hold and there is almost certainly going to be a clamour More >
about 2 years ago - 3 comments
In response to yesterday’s post about inlining CSS for HTML emails, I got a couple of comments suggesting alternatives to my CSS parser class. Not wanting to have to maintain code unless I have to, I decided to give them both a try and see how they worked out.
TamTam
First up is TamTam, suggested by batnight. More >
about 2 years ago - Comments Off
It’s surprising given drupal’s popularity that there aren’t more books covering it in detail. Site launches and contributions by the likes of lullabot and bryght have pushed the CMS’ profile and recent releases have emphasised the Web 2.0 potential, but a quick look at amazon reveals only four related titles. Of the four, Pro Drupal More >
about 2 years ago - 2 comments
As I’ve indicated here a few times, when announcing site launches and offering a few hints and tips, I fairly frequently find myself working with Drupal but have long had reservations about doing so. What I’ve so far avoided doing is going into much detail about why that would be, what those reservations are, and More >
about 4 years ago
Great work!
I wonder if there is any docs or examples acting as a proof of concept.
Thanks
Dinh
http://www.goldenkey.edu.vn/en
about 4 years ago
Thanks. So far I’ve been focussed on getting the code as stable and effective as possible. I think that it’s now approaching stability and the next focus will be on documentation and testing.
A very quick example is available at http://jystewart.net/code/feedparser/
btw: if anyone knows of non-UTF8/ISO8859-1 feeds I could use for testing, that’d be really helpful.
about 4 years ago
Your example is great. It works with my blog feed: http://www.phpvietnam.net/blog/index.php/feed/ (unicode – utf-8)
Thank you very much and I will keep your solution in mind whenever I need a XML Parsing Library for PHP 5.
Dinh
http://www.goldenkey.edu.vn/en
about 4 years ago
More feeds to test:
Successful: http://spaces.msn.com/members/wudicgi/feed.rss (Chinese on MSN blog)
http://spaces.msn.com/members/leonidlukin/feed.rss (Russian)
Unsuccessful: http://weblabor.hu/rss/hozzaszolas/hirek/20051008/phpkapcsolat (Hungary utf-8)
http://weblabor.hu/rss/hozzaszolas/hirek/20051008/phpkapcsolat?encoding=iso-8859-2
Not an easy success: http://www.proustcafe.com/index.xml (RSS 2.0 UTF-8 but some characters are displayed as squares.
about 4 years ago
Thanks for the examples. Both of the Hungarian examples (marked ‘unsuccessful’) are actually RSS 0.92 which is not supported by the parser at present. I had been hoping not to have to support versions of RSS
about 4 years ago
I have tried your example several times and got an error when parsing http://www.bytefx.com/blog/SyndicationService.asmx/GetRssCategory?categoryName=MySQL
The error is displayed as follows:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\server\webroot\phplearning\XML_Feed_Parser.php on line 23
Is there is any way to reset that default time out setting?
Thanks a lot.
Dinh
http://www.goldenkey.edu.vn/en
about 4 years ago
That’s defined in your php.ini file. You’ll need to change the ‘max_execution_time’ directive.
Are you sure that the problem was with the parser and not with code fetching the feed? If so, please file a bug report through the PEAR website. There’s a link from http://pear.php.net/package/XML_Feed_Parser to the bugs system.
about 4 years ago
Hello James,
Do you think that XML_Feed_Parser should throw a exception in case a user tries to parse an unsupported XML Format such as RSS 0.92. The current version of XML_Feed_Parser return a blank page so users can be confused: the feed has nothing to display or the parser can not get the information.
I dont think this is a bug but a RFE. Please correct me if I am wrong.
Thanks and best regards
Dinh
http://www.goldenkey.edu.vn/en
about 4 years ago
Um. It’s supposed to throw an exception if it doesn’t recognise the feed type, hence using the try {} catch {} block in the example. And the package doesn’t ever return ‘pages’ — it’s the job of your code to turn its results into a page (or whatever else you want to produce)
If it’s not throwing an exception, that’s a bug. If it’s timing out then that’s probably a bug too.
about 4 years ago
Ah. There is indeed a bug whereby the main parser class doesn’t throw an exception if the feed type is a version of RSS that is not supported. That is fixed in CVS (I’ve also added 0.91 and 0.92 support to CVS) and will be resolved in the next version (which I hope to get out this weekend).
about 4 years ago
I just upgraded XML_Feed_Parser to version 0.26 and am happy to find that the exception has been improved. I have tested it with Atom 0.3: http://b2evolution.net/xmlsrv/atom.php?blog=7
I changed my script a bit ( put $feed_xml = file_get_contents($feedFile); into the try.. catch block) with a hope that an exception will be thrown when it is instructed to parse a non-existent feed or not-a-feed XML/HTML file but it seems that these problems has not been covered yet.
Besides, an fatal error (not an exception) will occur if the connection fails, a website on and up but it is behind a firewall.
Thanks and best regards,
Dinh
about 4 years ago
Where the file_get_contents() sits is not going to change whether or not the feed parser throws an error, but you’re right that it should be checking for empty/non-XML input and throwing an exception in that case. That will be in the next version.
As to the fatal error, this package deliberately does not provide HTTP functionality. How you retrieve the feed is your business and not something that will be addressed here. The example I offer is a very simple one as I am demonstrating the parser, not feed fetching. Obviously in production environments I use much more robust approaches.