[FLOW3-general] Elegant/Clean way to consume Web APIs in a FLOW3 app?

Jacob Floyd cognifloyd at gmail.com
Thu Sep 6 01:21:03 CEST 2012


Hello everyone,

There are a lot of Web APIs across the internet (imagine that). Some APIs 
are truly RESTful (identifying resources and using the standard HTTP verbs, 
while including hypermedia links to explain how to navigate the API). Some 
APIs are more RPC-ish. FLOW3 has a more RPC-ish model by default. By RPC, I 
mean that we specify the controller/action in the URI of the HTTP request.

This RPC-like API is a very common design across the internet. In the 
ColdFusion world, for example, you often specify a particular method using 
a "service=Handler.Service" parameter (Where Handler is the controller, and 
Service is the action). From quick googling, it looks like ASP.net and 
other languages also make such RPC APIs fairly straight forward to build.

So, what is the FLOW3 way of consuming those RPC-style APIs? What about 
RESTful APIs?

When it comes to talking with external services, I see the following ways 
of doing this:
* Using FLOW3's persistence layer (Doctrine.*; 
TYPO3.CouchDB; De.Netlogix.Solr)
* Using a library of some sort (LDAP as an Authentication Provider; 
TYPO3.Queue.Beanstalkd uses Pheanstalk; TYPO3.Queue.Redis uses Predis)
* Using Http\Client\Browser (ElasticSearch\Transfer)

Conceivably, a FLOW3 package that implements the Persistence layer 
interface could use a library in another FLOW3 package that in turn uses 
FLOW3's Http\Client\Browser to send HTTP requests to the external API or 
service. Whether or not someone would actually want to implement all that I 
don't know.

So, if I want to consume an RPC-style API in a reusable fashion, I could 
create a FLOW3 package that implements a beautiful PHP API but uses 
Http\Client\Browser to send\receive the API hits to the external service. 
Would that be "clean"? Would that be "the FLOW3 way"? How else would you 
talk with some API or other?

Cheers,
Jacob Floyd


More information about the FLOW3-general mailing list