I am developing a web page on which I am accepting input words from the user, and when the user submits those words, I want to display definition of those words, or wikipedia links of those words for more definition about that word -- something like the following:
Let's say user enetered 5 words:
toast, egg, beans, coffee, tea
Now I want to display them like:
toast › slices of bread that have been toasted
egg › animal reproductive body consisting of an ovum or embryotogether with nutritive and protective envelopes
beans › a small skullcap <link to wikipedia>read more on wikipedia</link>
coffee › a beverage consisting of an infusion of ground coffee beans
tea › a beverage made by steeping tea leaves in water <link to wikipedia>read more on wikipedia</link>
For those words for which there is no article on wikipedia, no wiki link would be displayed.
Can someone please suggest me some open-source PHP script or package that would do this for me? Alternatively, I'd appreciate any suggestions on how to do this in PHP.
I am more interested in getting data from some other website directly than I am in storing word definitions in my database.
I am using PHP and MySQL.
Explode user's sanitized input into single words by using explode()
function and then use Wikipedia API (see api.php) to get definitions or wiki links.
There should be other web services apart from Wikipedia which is providing API access, just Google them. Also this could be a good guide if you want to make it in Javascript.
As a whole, A well-formed API is not language-dependent. Usually it's XML or JSON (see API Data formats, serialized PHP included), for the XML case you can use the native PHP SimpleXML (Guide here) or SimplePie library. just get & parse!