Re: How to build a joomla module for consuming a webservice returning xml/json?

1,209 views
Skip to first unread message

SpiralScripts

unread,
Oct 30, 2012, 9:04:41 AM10/30/12
to joomla-de...@googlegroups.com
There are various options for this. There are basically 3 main tasks you need to do: 1. fetch the feed 2. parse the feed 3. render the results

To fetch the feed you can use curl, or file_get_contents if you have allow_url_fopen turned on.

To parse the feed, if the feed is in RSS format you can use the simplepie library which comes bundled with Joomla, it includes various functions for reading RSS and atom feeds (it will also fetch the feed). Otherwise you can use simpleXML to parse the feed yourself.

What you do with it then is up to you.

There is also SOAP, which I have only a sketchy knowledge of.


On Monday, 29 October 2012 15:08:33 UTC, xalibeut wrote:
Hi,
any idea/example on how to build a joomla module that will consume an external webservice returning json/xml data?
Thanks for your help.

piotr_cz

unread,
Oct 31, 2012, 6:40:33 AM10/31/12
to Joomla! General Development
I'd recommend JHttp package for connecting to APIs.
- manual: http://developer.joomla.org/platform-manual.html
- code: https://github.com/joomla/joomla-platform/tree/staging/libraries/joomla/http

And something like this for echoing JSON output:
https://github.com/joomla/joomla-platform/pull/1596

But probably you want to create a component or separate application as
modules are better for HTML chunks that become part of web page. It
all depends, what will consume this output.
Reply all
Reply to author
Forward
0 new messages