Multiple REST Feeds to MYSQL Database - Using PHP - php

I've got a number of REST feeds I'd like to store in a MYSQL database, can anyone suggest a solution for this? Something PHP related appreciated....

It's not PHP related, but PERL has both a REST interface and a DBI interface (for interfacing with MYSQL).
http://metacpan.org/pod/WWW::REST
There are many other REST interfaces for Google, Twitter, etc. Just search CPAN modules at search.cpan.org

To my knowledge there is no such thing as a REST feed. There are RSS feeds and Atom feeds, so I will assume you are talking about one of those.
Both are based on XML so I suggest you find an XML parser for PHP and do an HTTP request to get the feed contents, parse the XML into a DOM and then copy the DOM data into MYSQL!
I'm not sure how to be more precise.
Are you looking for someone to write the code?

Ok, I'm assuming you are talking about "RSS" feeds. Here's a great opensource library that makes it easy -- http://simplepie.org/ . Point it at an RSS or Atom feed, it will give you back PHP arrays and objects. From there you can interpret them and save them any way you want.
Depending on what you actually want to do with the database, you could use RSS as an XML clob format. Not fast, but easy. Again, it totally depends on what you want to do with the database.

Related

Is there a XML decoder for PHP objects?

I am build a application in Delphi that stores some configuration that is not going to be passive to query filters on the database. So I decided to create some blob text fields to store those configurations that will only be used as keys to configure some modules of the application.
In this Delphi side of the application, I am using NativeXML run-time components to decode the configuration class or record type of each module into/from XML and populate that field on the database.
My problem came when I realized that this application will have a web site module where people will register for clinical attending and this part will need to use some of the configuration stored on that XML on the database. So...
I am newbie on PHP and I wish to know from you if PHP has the ability to do that XML<->Object\Record DeCoding or do I have to look for a library that makes it possible?
Note: If there is only a record type capacity, I will use it, but if not, I prefer to use classes
Edit:
In response to some comments on answers, I would say that I use XML instead of JSON because of this Delphi XML library that suited me well! If someone could point me to a goo JSON DeCode library to convert JSON<->Delphi Objects will really use it instead of XML because I like to work with JSON. Would that solve the problem on the PHP parsing?
That is not that easy in PHP. However there are lots of smart folks out there, who where facing the same problem.
Paul Ferrertt has a XML-Encode Class here:
http://www.paulferrett.com/2009/encoding-an-object-in-xml-with-php/
In PHP there are multiple functions to decode a XML sheet. Start here:
http://www.php.net/manual/en/refs.xml.php
http://php.net/manual/en/function.xml-parse.php
However you won' t be able to get an object back as easy as with json_decode() and that for a reason XML is not meant to transfer objects (and the like) around. You have to write your own conversion methods.
I suggest you to read this : http://www.php.net/manual/en/refs.xml.php. Some of these libraries are easier to use that are others, some others are more powerful, etc.

Automatically generate RSS feeds

I have information stored in a database that I want to use to create RSS feeds.
What is the best way to do this?
Also, are there any PHP library/functions that I can pass the data to and they will take care of ensuring that any characters that need to be encoded/stripped are dealt with?
PHP Universal Feed Generator is the one you are looking for.
It supports RSS 1.0, RSS 2.0 and ATOM
If you know how to dynamically create an XML, it's pretty much the same, you just need to look on way to format an RSS, and off you go.
After you created the rss - you can validate it here:
http://validator.w3.org/feed/
Here is a short wiki article on how it's supposed to be formatted: http://en.wikipedia.org/wiki/Rss
I prefer the Zend_Feed component, which is part of Zend Framework. Just have a look at Zend_Feed_Writer in the Reference Guide, to see how to export data as a feed.
http://careers.stackoverflow.com/jobs/feed
Just look at this RSS-example (right click for Source Code). It's a functional and used RSS and all you really need is to create a HTML-similiar page with dynamic data yourself.
EDIT:
I personally don't see the point of using a plugin for this. It's so similiar to HTML that you may aswell just create it with given tags in above example.

Is there any reason to use XML/XSLT when using a PHP/MySQL App?

I have been making HTML/PHP/MySQL database apps for quite a while now. I have avoided using XML/XSLT in any application since I just pull the data out and format it within my PHP script, and display it.
Assuming I am not wanting my data to be portable to other people's applications (via XML), is there any reason to implement an XML/XSLT based web app or is it a matter of preference?
Thanks.
I use XML/XSLT as a template engine.
Througout my script, I gather my data as nodes and put them in an XML object. When I need to display data, I feed this XML object to an XSLT and display the result.
It is a matter of preference.
XML/XSLT are useful when transforming XML to multiple other XML formats (rss, xhtml etc...), so if you don't need this kind of functionality, don't go with it.
They also add a cost in complexity and processing power. Again, if you don't need it, don't use them.

How to produce a merged RSS feed (from DokuWiki and Serendipity)

I've got an application developed on top of DokuWiki. I'd like to provide a 'News' page providing the latest updates from the internal RSS feed, some other feeds maintained in Serendipity and potentially other locations.
Although its trivial to attach feed parsers to each one individually, I'd like to aggregate this into a single list (possibly a single RSS feed).
Both the DokuWiki and Serendipity servers are not connected to the internet - so I can't use an external service for this - looking for code.
Anybody got any ideas?
TIA
C.
Basically speaking, you'll have to :
Fetch the entries from both feeds
Merge them into an array of entries
Create a new feed, with your own headers, and containing those entries.
A couple of tools that could probably help :
Zend_Feed_Reader, for the first part
and Zend_Feed_Writer, for the second part
And you might want to take a look at padraic / ZFPlanet : it's an aggregator -- there are probably some ideas in there that could help you get started ;-)
DokuWiki already comes with the SimplePie feed aggregation library so you can use that without the need for any additional libraries. Some tips on how to merge two feeds can be found in their documentation:
http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date
http://simplepie.org/wiki/faq/typical_multifeed_gotchas

RSS or XML

I need to get data from a web site written in PHP. My boss wants me to provide an RSS feed to get updated content.
The problem is that I need to provide several informations (at least a dozen different field). Is returning data as XML a better way than RSS?
RSS is a form of XML.
If you find yourself outputting the same sorts of data as what is in the RSS specification, it definately doesn't hurt to output in the RSS spec. That way, you can syndicate your content.
It's really going to depend on what the data is and how it's going to be consumed.
RSS is XML, but it's XML meant to syndicate data with a consistent format (there's a pretty good overview here: http://cyber.law.harvard.edu/rss/rss.html), and that allows feed readers and other consumers to know how to process and display them. So if your boss wants to look at this data in his or her feed reader of choice, then go for RSS.
If the data is more varied or arbitrary, and is going to be consumed by some sort of application or other processor on the other end, then XML is probably a better solution.
RSS is an XML schema that's good for publishing articles, news, bulletins. RSS will be very consumable - every device and app, it seems, knows how to consume RSS.
A custom XML schema may fit you better based on your requirements for all the different fields. But you will not have a vast audience of ready consumers for that schema.
Some questions you might ask yourself:
who do I want to consume this information? A wide variety, basically "everybody"? Or is it going to be consumed by a limited audience, let's say 3 or 4 partner companies. IF the former, that tends to recommend RSS. If the latter, it is neutral.
what information do you really need to convey? Will it fit nicely in an RSS Schema? If not, that recommends a custom XML schema. If it does ffit in RSS, why not use it.
You have to weigh the importance of your answers to get to a conclusion.

Categories