Previous Next

Zend_Service_Audioscrobbler

Introduction to Searching Audioscrobbler

Zend_Service_Audioscrobbler is a simple API for using the Audioscrobbler REST Web Service. The Audioscrobbler Web Service provides access to its database of Users, Artists, Albums, Tracks, Tags, Groups, and Forums. The methods of the Zend_Service_Audioscrobbler class begin with one of these terms. The syntax and namespaces of the Audioscrobbler Web Service are mirrored in Zend_Service_Audioscrobbler. For more information about the Audioscrobbler REST Web Service, please visit the » Audioscrobbler Web Service site.

Users

In order to retrieve information for a specific user, the setUser() method is first used to select the user for which data are to be retrieved. Zend_Service_Audioscrobbler provides several methods for retrieving data specific to a single user:

  • userGetProfileInformation(): Returns a SimpleXML object containing the current user's profile information.

  • userGetTopArtists(): Returns a SimpleXML object containing a list of the current user's most listened to artists.

  • userGetTopAlbums(): Returns a SimpleXML object containing a list of the current user's most listened to albums.

  • userGetTopTracks(): Returns a SimpleXML object containing a list of the current user's most listened to tracks.

  • userGetTopTags(): Returns a SimpleXML object containing a list of tags most applied by the current user.

  • userGetTopTagsForArtist(): Requires that an artist be set via setArtist(). Returns a SimpleXML object containing the tags most applied to the current artist by the current user.

  • userGetTopTagsForAlbum(): Requires that an album be set via setAlbum(). Returns a SimpleXML object containing the tags most applied to the current album by the current user.

  • userGetTopTagsForTrack(): Requires that a track be set via setTrack(). Returns a SimpleXML object containing the tags most applied to the current track by the current user.

  • userGetFriends(): Returns a SimpleXML object containing the user names of the current user's friends.

  • userGetNeighbours(): Returns a SimpleXML object containing the user names of people with similar listening habits to the current user.

  • userGetRecentTracks(): Returns a SimpleXML object containing the 10 tracks most recently played by the current user.

  • userGetRecentBannedTracks(): Returns a SimpleXML object containing a list of the 10 tracks most recently banned by the current user.

  • userGetRecentLovedTracks(): Returns a SimpleXML object containing a list of the 10 tracks most recently loved by the current user.

  • userGetRecentJournals(): Returns a SimpleXML object containing a list of the current user's most recent journal entries.

  • userGetWeeklyChartList(): Returns a SimpleXML object containing a list of weeks for which there exist Weekly Charts for the current user.

  • userGetRecentWeeklyArtistChart(): Returns a SimpleXML object containing the most recent Weekly Artist Chart for the current user.

  • userGetRecentWeeklyAlbumChart(): Returns a SimpleXML object containing the most recent Weekly Album Chart for the current user.

  • userGetRecentWeeklyTrackChart(): Returns a SimpleXML object containing the most recent Weekly Track Chart for the current user.

  • userGetPreviousWeeklyArtistChart($fromDate, $toDate): Returns a SimpleXML object containing the Weekly Artist Chart from $fromDate to $toDate for the current user.

  • userGetPreviousWeeklyAlbumChart($fromDate, $toDate): Returns a SimpleXML object containing the Weekly Album Chart from $fromDate to $toDate for the current user.

  • userGetPreviousWeeklyTrackChart($fromDate, $toDate): Returns a SimpleXML object containing the Weekly Track Chart from $fromDate to $toDate for the current user.

Example #1 Retrieving User Profile Information

In this example, we use the setUser() and userGetProfileInformation() methods to retrieve a specific user's profile information:

setUser('BigDaddy71'); // Set the user whose profile information we want to retrieve
$profileInfo = $as->userGetProfileInformation(); // Retrieve BigDaddy71's profile information
print "Information for $profileInfo->realname can be found at $profileInfo->url"; // Display some of it

Example #2 Retrieving a User's Weekly Artist Chart

setUser('lo_fye'); // Set the user whose profile weekly artist chart we want to retrieve
$weeks = $as->userGetWeeklyChartList(); // Retrieves a list of previous weeks for which there are chart data
if (count($weeks) < 1) {
    echo 'No data available';
}
sort($weeks); // Order the list of weeks

$as->setFromDate($weeks[0]); // Set the starting date
$as->setToDate($weeks[0]); // Set the ending date

$previousWeeklyArtists = $as->userGetPreviousWeeklyArtistChart();

echo 'Artist Chart For Week Of ' . date('Y-m-d h:i:s', $as->from_date) . '
'; foreach ($previousWeeklyArtists as $artist) { // Display the artists' names with links to their profiles print '' . $artist->name . '
'; }

Artists

Zend_Service_Audioscrobbler provides several methods for retrieving data about a specific artist, specified via the setArtist() method:

  • artistGetRelatedArtists(): Returns a SimpleXML object containing a list of Artists similar to the current Artist.

  • artistGetTopFans(): Returns a SimpleXML object containing a list of Users who listen most to the current Artist.

  • artistGetTopTracks(): Returns a SimpleXML object containing a list of the current Artist's top-rated Tracks.

  • artistGetTopAlbums(): Returns a SimpleXML object containing a list of the current Artist's top-rated Albums.

  • artistGetTopTags(): Returns a SimpleXML object containing a list of the Tags most frequently applied to current Artist.

Example #3 Retrieving Related Artists

setArtist('LCD Soundsystem'); // Set the artist for whom you would like to retrieve related artists
$relatedArtists = $as->artistGetRelatedArtists(); // Retrieve the related artists
foreach ($relatedArtists as $artist) {
    print '' . $artist->name . '
'; // Display the related artists }

Tracks

Zend_Service_Audioscrobbler provides two methods for retrieving data specific to a single track, specified via the setTrack() method:

  • trackGetTopFans(): Returns a SimpleXML object containing a list of Users who listen most to the current Track.

  • trackGetTopTags(): Returns a SimpleXML object containing a list of the Tags most frequently applied to the current Track.

Tags

Zend_Service_Audioscrobbler provides several methods for retrieving data specific to a single tag, specified via the setTag() method:

  • tagGetOverallTopTags(): Returns a SimpleXML object containing a list of Tags most frequently used on Audioscrobbler.

  • tagGetTopArtists(): Returns a SimpleXML object containing a list of Artists to whom the current Tag was most frequently applied.

  • tagGetTopAlbums(): Returns a SimpleXML object containing a list of Albums to which the current Tag was most frequently applied.

  • tagGetTopTracks(): Returns a SimpleXML object containing a list of Tracks to which the current Tag was most frequently applied.

Groups

Zend_Service_Audioscrobbler provides several methods for retrieving data specific to a single group, specified via the setGroup() method:

  • groupGetRecentJournals(): Returns a SimpleXML object containing a list of recent journal posts by Users in the current Group.

  • groupGetWeeklyChart(): Returns a SimpleXML object containing a list of weeks for which there exist Weekly Charts for the current Group.

  • groupGetRecentWeeklyArtistChart(): Returns a SimpleXML object containing the most recent Weekly Artist Chart for the current Group.

  • groupGetRecentWeeklyAlbumChart(): Returns a SimpleXML object containing the most recent Weekly Album Chart for the current Group.

  • groupGetRecentWeeklyTrackChart(): Returns a SimpleXML object containing the most recent Weekly Track Chart for the current Group.

  • groupGetPreviousWeeklyArtistChart($fromDate, $toDate): Requires setFromDate() and setToDate(). Returns a SimpleXML object containing the Weekly Artist Chart from the current fromDate to the current toDate for the current Group.

  • groupGetPreviousWeeklyAlbumChart($fromDate, $toDate): Requires setFromDate() and setToDate(). Returns a SimpleXML object containing the Weekly Album Chart from the current fromDate to the current toDate for the current Group.

  • groupGetPreviousWeeklyTrackChart($fromDate, $toDate): Returns a SimpleXML object containing the Weekly Track Chart from the current fromDate to the current toDate for the current Group.

Forums

Zend_Service_Audioscrobbler provides a method for retrieving data specific to a single forum, specified via the setForum() method:

  • forumGetRecentPosts(): Returns a SimpleXML object containing a list of recent posts in the current forum.

Previous Next
Introduction to Zend Framework
Overview
Installation
Zend_Acl
Introduction
Refining Access Controls
Advanced Use
Zend_Auth
Introduction
Database Table Authentication
Digest Authentication
HTTP Authentication Adapter
LDAP Authentication
Open ID Authentication
Zend_Cache
Introduction
The theory of caching
Zend_Cache frontends
Zend_Cache backends
Zend_Captcha
Introduction
Captcha Operation
Captcha Adapters
Zend_Config
Introduction
Theory of Operation
Zend_Config_Ini
Zend_Config_Xml
Zend_Console_Getopt
Introduction to Getopt
Declaring Getopt Rules
Fetching Options and Arguments
Configuring Zend_Console_Getopt
Zend_Controller
Zend_Controller Quick Start
Zend_Controller Basics
The Front Controller
The Request Object
The Standard Router: Zend_Controller_Router_Rewrite
The Dispatcher
Action Controllers
Action Helpers
The Response Object
Plugins
Using a Conventional Modular Directory Structure
MVC Exceptions
Migrating from Previous Versions
Zend_Currency
Introduction to Zend_Currency
How to work with currencies
Migrating from Previous Versions
Zend_Date
Introduction
Theory of Operation
Basic Methods
Zend_Date API Overview
Creation of dates
Constants for General Date Functions
Working examples
Zend_Db
Zend_Db_Adapter
Zend_Db_Statement
Zend_Db_Profiler
Zend_Db_Select
Zend_Db_Table
Zend_Db_Table_Row
Zend_Db_Table_Rowset
Zend_Db_Table Relationships
Zend_Debug
Dumping Variables
Zend_Dojo
Introduction
Zend_Dojo_Data: dojo.data Envelopes
Dojo View Helpers
Dojo Form Elements and Decorators
Zend_Dom
Introduction
Zend_Dom_Query
Zend_Exception
Using Exceptions
Zend_Feed
Introduction
Importing Feeds
Retrieving Feeds from Web Pages
Consuming an RSS Feed
Consuming an Atom Feed
Consuming a Single Atom Entry
Modifying Feed and Entry structures
Custom Feed and Entry Classes
Zend_File
Zend_File_Transfer
Validators for Zend_File_Transfer
Zend_Filter
Introduction
Standard Filter Classes
Filter Chains
Writing Filters
Zend_Filter_Input
Zend_Filter_Inflector
Zend_Form
Zend_Form
Zend_Form Quick Start
Creating Form Elements Using Zend_Form_Element
Creating Forms Using Zend_Form
Creating Custom Form Markup Using Zend_Form_Decorator
Standard Form Elements Shipped With Zend Framework
Standard Form Decorators Shipped With Zend Framework
Internationalization of Zend_Form
Advanced Zend_Form Usage
Zend_Gdata
Introduction to Gdata
Authenticating with AuthSub
Authenticating with ClientLogin
Using Google Calendar
Using Google Documents List Data API
Using Google Spreadsheets
Using Google Apps Provisioning
Using Google Base
Using the YouTube Data API
Using Picasa Web Albums
Catching Gdata Exceptions
Zend_Http
Zend_Http_Client - Introduction
Zend_Http_Client - Advanced Usage
Zend_Http_Client - Connection Adapters
Zend_Http_Cookie and Zend_Http_CookieJar
Zend_Http_Response
Zend_InfoCard
Introduction
Zend_Json
Introduction
Basic Usage
JSON Objects
XML to JSON conversion
Zend_Json_Server - JSON-RPC server
Zend_Layout
Introduction
Zend_Layout Quick Start
Zend_Layout Configuration Options
Zend_Layout Advanced Usage
Zend_Ldap
Introduction
Zend_Loader
Loading Files and Classes Dynamically
Loading Plugins
Zend_Locale
Introduction
Using Zend_Locale
Normalization and Localization
Working with Dates and Times
Supported Languages for Locales
Supported Regions for Locales
Zend_Log
Overview
Writers
Formatters
Filters
Zend_Mail
Introduction
Sending via SMTP
Sending Multiple Mails per SMTP Connection
Using Different Transports
HTML E-Mail
Attachments
Adding Recipients
Controlling the MIME Boundary
Additional Headers
Character Sets
Encoding
SMTP Authentication
Securing SMTP Transport
Reading Mail Messages
Zend_Measure
Introduction
Creation of Measurements
Outputting measurements
Manipulating Measurements
Types of measurements
Zend_Memory
Overview
Memory Manager
Memory Objects
Zend_Mime
Zend_Mime
Zend_Mime_Message
Zend_Mime_Part
Zend_OpenId
Introduction
Zend_OpenId_Consumer Basics
Zend_OpenId_Provider
Zend_Paginator
Introduction
Usage
Configuration
Advanced usage
Zend_Pdf
Introduction.
Creating and loading PDF documents.
Save changes to the PDF document.
Document pages.
Drawing.
Document Info and Metadata.
Zend_Pdf module usage example.
Zend_Registry
Using the Registry
Zend_Rest
Introduction
Zend_Rest_Client
Zend_Rest_Server
Zend_Search_Lucene
Overview
Building Indexes
Searching an Index
Query Language
Query Construction API
Character Set
Extensibility
Interoperating with Java Lucene
Advanced
Best Practices
Zend_Server
Introduction
Zend_Server_Reflection
Zend_Service
Introduction
Zend_Service_Akismet
Zend_Service_Amazon
Zend_Service_Audioscrobbler
Zend_Service_Delicious
Zend_Service_Flickr
Zend_Service_Nirvanix
Zend_Service_ReCaptcha
Zend_Service_Simpy
Introduction
Zend_Service_StrikeIron
Zend_Service_StrikeIron: Bundled Services
Zend_Service_StrikeIron: Advanced Uses
Zend_Service_Technorati
Zend_Service_Yahoo
Zend_Session
Introduction
Basic Usage
Advanced Usage
Global Session Management
Zend_Session_SaveHandler_DbTable
Zend_Soap
Zend_Soap_Server
Zend_Soap_Client
WSDL Accessor
AutoDiscovery. Introduction
Class autodiscovering.
Functions autodiscovering.
Autodiscovering. Datatypes.
Zend_Test
Introduction
Zend_Test_PHPUnit
Zend_Text
Zend_Text_Figlet
Zend_TimeSync
Introduction
Working with Zend_TimeSync
Zend_Translate
Introduction
Adapters for Zend_Translate
Using Translation Adapters
Zend_Uri
Zend_Uri
Zend_Validate
Introduction
Standard Validation Classes
Validator Chains
Writing Validators
Zend_Version
Reading the Zend Framework Version
Zend_View
Introduction
Controller Scripts
View Scripts
View Helpers
Zend_View_Abstract
Zend_Wildfire
Zend_Wildfire
Zend_XmlRpc
Introduction
Zend_XmlRpc_Client
Zend_XmlRpc_Server
Zend Framework Requirements
PHP Version
PHP Extensions
Zend Framework Components
Zend Framework Dependencies
Zend Framework Coding Standard for PHP
Overview
PHP File Formatting
Naming Conventions
Coding Style
Copyright Information