Zend Framework: Zend_Service_Audioscrobbler Component Proposal
| Proposed Component Name | Zend_Service_Audioscrobbler |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Service_Audioscrobbler |
| Proposers | Chris Hartjes Derek Martin |
| Revision | 1.0 - 1 July 2006 (wiki revision: 20) |
Table of Contents
1. Overview
Zend_Service_Audioscrobbler provides a simple API to access Audioscrobbler's web services
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
- A simple API for accessing Audioscrobbler's web services
4. Dependencies on Other Framework Components
- Zend_Service_Rest
- Zend_Service_Exception
5. Theory of Operation
Results from Audioscrobbler's REST services are returned as SimpleXML objects, otherwise a Zend_Service_Exception is thrown containing an informative error message.
6. Milestones / Tasks
alpha 0.01 released November 15th, 2006
7. Class Index
- Zend_Service_Audioscrobbler
8. Use Cases
| UC-01 |
|---|
| UC-02 |
|---|
| UC-03 |
|---|
9. Class Skeletons
Zend_Service_Audioscrobbler __construct ()
void albumGetInfo ()
SimpleXML artistGetRelatedArtists ()
SimpleXML artistGetTopAlbums ()
SimpleXML artistGetTopFans ()
SimpleXML artistGetTopTags ()
SimpleXML artistGetTopTracks ()
void get ( $field, string $key)
void group ()
void groupGetWeeklyArtistChartList ()
void groupGetWeeklyChartList ()
void set (string $field, $value, string $val)
void tagGetTopArtists ()
void tagGetTopTags ()
void tagGetTopTracks ()
void trackGetTopFans ()
void trackGetTopTags ()
SimpleXML userGetFriends ()
SimpleXML userGetNeighbours ()
array userGetProfileInformation ()
SimpleXML userGetRecentBannedTracks ()
SimpleXML userGetRecentLovedTracks ()
SimpleXML userGetRecentTracks ()
SimpleXML userGetTopAlbums ()
array userGetTopArtists ()
SimpleXML userGetTopTags ()
SimpleXML userGetTopTagsForAlbum ()
SimpleXML userGetTopTagsForArtist ()
SimpleXML userGetTopTagsForTrack ()
SimpleXML userGetTopTracks ()
SimpleXML userGetWeeklyAlbumChart ($from, $to)
SimpleXML userGetWeeklyArtistChart ($from, $to)
SimpleXML userGetWeeklyChartList ()
SimpleXML userGetWeeklyTrackChart ($from, $to)
10 Comments
comments.show.hideJul 11, 2006
Matthew Ratzloff
I'll confess that I don't know what Audioscrobbler is, but surely there is a better way to implement an interface to it than a class with almost 60 methods.
Isn't it possible to split it up somehow?
Jul 29, 2006
Derek Martin
Hi Matthew.
Audioscrobbler is a site that tracks what you listen to via their iTunes/Winamp/etc plug-in installed, or via streaming audio at http://www.last.fm
Our goal was to simply provide a php interface to Audioscrobbler's existing web service. There is a 1:1 correlation between our methods and their service URLs, right down to the method naming.
We would have loved not to have 60 methods, but then our API wouldn't correlate to theirs. Plus, that would have meant more thinking for us
ttys,
Derek
Aug 28, 2006
Simon Mundy
Perhaps you could use __call to transparently pass methods to the Audioscrobbler object and then throw an error only if the Audioscrobbler method is non-existent? It would mean a much leaner component and probably a lot less work to maintain it whenever the service is upgraded.
Sep 28, 2006
Chris Hartjes
I haven't used __call much so I'll take a look at that. If it makes for a better component, I'm definitely in favour of it.
Sep 28, 2006
Chris Hartjes
Yeah, I've been doing a bunch of work on this lately and have simplified a lot of the function calls to minimize duplication. Check out the latest in SVN in the incubator
Jul 30, 2006
Elisamuel Resto
I use Last.fm and I love it, but I must ask, is the framework a good place to have this? I see uses for the Amazon, Flickr and Yahoo! service implementations, but how would this one be beneficial to the framework apart from providing some interaction with the framework?
Aug 28, 2006
Gavin
Aug 29, 2006
Darby Felton
The proposal is approved on the condition that the following issues are addressed by the proposal author.
Public properties make the set* methods redundant. Ideas for resolution:
Another option would be to pass the "properties" as method arguments:
No underscores within variable names and compliance with other coding standards.
What is the reason that setDate() and getInfo() methods are designated private? Should they not be inherited and accessible by subclasses, and if so, why not?
We should leverage Zend_Date as it becomes available for date-specific operations.
How do Zend_Service_Audioscrobbler and the Audioscrobbler web services support limiting the number of records returned by a request?
The API presented causes extra effort to programmatically select functionality, due to the practice of essentially embedding options into the method names. Usually function names accept parameters to select between different, related behaviors. For example, the proposal shows:
Using class constants having string values we could nicely refactor the above list of methods to something like:
Similarly, what about:
Sep 28, 2006
Chris Hartjes
Hi Darby,
I've finally managed to set some time aside to address these issues. Here are my thoughts:
That really does make sense and is consistent
That was just silly on our part in the first place
Thanks again for all the great suggestions.
Mar 30, 2007
Christian Gräfe
Thank you for implementing the interface to the Audioscrobbler web service in Zend Framework! Currently, there is an annoying bug in the private getInfo() method, though. The following code example:
results in a PHP Fatal error:
PHP Fatal error: Call to a member function getStatus() on a non-object in /var/httpd/servers/noise.graefe.net/lib/ZendFramework-0.9.1-Beta/library/Zend/Service/Audioscrobbler.php on line 165
My suggestion is to change the error handling in getInfo() to something like this:
I would have opened an issue in the tracker but either I'm to blind to find the button to do so, or I'm not allowed to.