问题
I need a PHP library/script that can retreive data from feeds, no matter if they are RSS or ATOM, because I want users to insert random feeds which will then be stored in a database. It would also be great if it could check whether a given URL is a feed or not.
If anything exists that could help me out, could anyone tell me? Thanks!
回答1:
Try these two, they both do RSS and Atom:
- SimplePie
- PHP Universal Feed Parser
回答2:
Zend_Feed
Zend_Feed provides functionality for consuming RSS and Atom feeds. It provides a natural syntax for accessing elements of feeds, feed attributes, and entry attributes. Zend_Feed also has extensive support for modifying feed and entry structure with the same natural syntax, and turning the result back into XML. In the future, this modification support could provide support for the Atom Publishing Protocol.
You don't have to use the entire Zend Framework, just take the Zend_Feed component and its dependencies.
回答3:
Recently I have created a php feed reader class which can parse both RSS and Atom feed. Here is the link http://raynux.com/blog/2009/09/02/rayfeedreader-php-class-for-parsing-rss-and-atom-feed/.
回答4:
This can be easily handled by SimpleXML and would require no code from anyone else but yourself. Just remember that SimpleXML will crap itself if you supply it a file that is invalid or doesn't exist. Use try/catch + execeptions.
http://us2.php.net/simplexml
来源:https://stackoverflow.com/questions/524024/is-there-a-php-feed-reader-for-both-rss-and-atom