Personally,

I am of the opinion that there are simply far too many web services for us to implement APIs for all of them. The few that we should implement should be:

a) Complex to use (the service, not our API!) or extensive
b) Commonly used by lots of developers
c) Not a moving target - versioning and maturity ensure our code doesn't get out dated.
d) Wrappers for multiple similar services

They don't need to fulfill all of the above, but pick 3 at least :)

Simple/minimal APIs should be handled by either 3rd party packages (and maybe a wiki page that lists them) or by
the individual developer using the upcoming Zend_WebService components being written by Matthew and myself.

WIth my new REST client, I have this:

$technorati = new Zend_Rest_Client('http://api.technorati.com/bloginfo');
$technorati->key($key);
$technorati->url('http://pixelated-dreams.com');
$result = $technorati->get();
echo $result->document->result->weblog->author->firstname .' '. $result->document->result->weblog->author->lastname;

This is still very much a work in progress. At lunch today I will change it so that the last line is not so ugly (this is because currently a SimpleXML document is returned for non-Zend_Rest_Server services). So, it'll be:

echo "$result->firstname $result->lastname";

And no, I'm not making special provisions for Technorati, but you /will/ need to know your API before hand, otherwise the above could result in  "Array Array" ;)

Also, I want to note that it does have a "fluent" API, so you can do:

$result = $technorati->key($key)->url("http://pixelated-dreams.com")->get();

I say "fluent", because whilst it works technically like a fluent API, its not close to human readable, if the service doesn't work that way (in this case :)

I could make this more fluent using something like:

$result = $technorati->action('bloginfo')->usingKey($key)->withUrl('http://pixelated-dreams.com')->get();

where the 'using' and 'with' are just prefixes to make it 'read' nicer. They are discarded. This of course causes a problem with what if you have a web service that uses those in their name. So I don't think this is a good idea ;)

I guess no matter what you do, unless you use the __ prefix (which only reduces the risk), there is always the potential for clashes between the code API and the Web Service API when using overloading. Such is life. :)

- Davey

On Sep 21, 2006, at 8:48 AM, Pádraic Brady wrote:

Hi,

I was considering raising a proposal for adding several additional web services I (at least) will be needing at some point in the future. It would be nice to add them to the Framework if they were acceptable. Suggestions would be:

- Exchange Rates (several sources, incl. UN, ECB and FRB)
- Technorati API

I thought I'd throw these two suggestions out there and see what folk thought about them. If they are deemed worthwhile adding to the Framework I'm willing to put together a proposal for at least one of them.

FYI: these are present in some form (even if only alpha) on PEAR. Haven't used PEAR's Exchange Rates implementation but it seems to cover the main sources in a Beta dated last November.

Thoughts?

Best regards,
Pádraic
 

Pádraic Brady
http://blog.quantum-star.com



Reply via email to