Example #1
0
 /** Get a list of members for this group.
  *
  * @param	string	$group	The group name to fetch the members of. (Required)
  * @return	array			An array of User objects.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function getMembers($group)
 {
     $xml = CallerFactory::getDefaultCaller()->call('group.getMembers', array('group' => $group));
     $users = array();
     foreach ($xml->children() as $user) {
         $users[] = User::fromSimpleXMLElement($user);
     }
     $perPage = Util::toInteger($xml['perPage']);
     return new PaginatedResult(Util::toInteger($xml['totalPages']) * $perPage, Util::toInteger($xml['page']) * $perPage, $perPage, $users);
 }
Example #2
0
 /** Get a Tasteometer score from two inputs, along with a list of shared artists. If the input is a User or a Myspace URL, some additional information is returned.
  *
  * @param	integer	$type1	A Tasteometer comparison type. (Required)
  * @param	integer	$type2	A Tasteometer comparison type. (Required)
  * @param	mixed	$value1	A last.fm username, an array of artist names or a myspace profile URL. (Required)
  * @param	mixed	$value2	A last.fm username, an array of artist names or a myspace profile URL. (Required)
  * @param	integer	$limit	How many shared artists to display (default = 5). (Optional)
  * @return	array			An array containing comparison results, input information and shared artists.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function compare($type1, $type2, $value1, $value2, $limit = null)
 {
     /* Handle arrays of artist names. */
     if (is_array($value1)) {
         $value1 = implode(',', $value1);
     }
     if (is_array($value2)) {
         $value2 = implode(',', $value2);
     }
     /* API call. */
     $xml = CallerFactory::getDefaultCaller()->call('tasteometer.compare', array('type1' => $type1, 'type2' => $type2, 'value1' => $value1, 'value2' => $value2, 'limit' => $limit));
     /* Get shared artists. */
     $artists = array();
     foreach ($xml->result->artists->children() as $artist) {
         $artists[] = Artist::fromSimpleXMLElement($artist);
     }
     /* Get input information. */
     $inputs = array();
     foreach ($xml->input->children() as $input) {
         $inputs[] = User::fromSimpleXMLElement($input);
     }
     return array('score' => Util::toFloat($xml->result->score), 'input' => $inputs, 'artists' => $artists);
 }
Example #3
0
 /** Get the top fans for this track on last.fm, based on listening data. Supply either track & artist name or MusicBrainz id.
  *
  * @param	string	$artist	The artist name in question. (Optional)
  * @param	string	$track	The track name in question. (Optional)
  * @param	string	$mbid	The MusicBrainz ID for the track. (Optional)
  * @return	array			An array of User objects.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function getTopFans($artist, $track, $mbid = null)
 {
     $xml = CallerFactory::getDefaultCaller()->call('track.getTopFans', array('artist' => $artist, 'track' => $track, 'mbid' => $mbid));
     $users = array();
     foreach ($xml->children() as $user) {
         $users[] = User::fromSimpleXMLElement($user);
     }
     return $users;
 }
Example #4
0
 /** Get a list of a user's neighbours on last.fm.
  *
  * @param	string	$user	The last.fm username to fetch the neighbours of. (Required)
  * @param	integer	$limit	An integer used to limit the number of neighbours returned. (Optional)
  * @return	array			An array of Track objects.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function getNeighbours($user, $limit = null)
 {
     $xml = CallerFactory::getDefaultCaller()->call('user.getNeighbours', array('user' => $user, 'limit' => $limit));
     $neighbours = array();
     foreach ($xml->children() as $neighbour) {
         $neighbours[] = User::fromSimpleXMLElement($neighbour);
     }
     return $neighbours;
 }
Example #5
0
 /** Get the top fans for an artist on last.fm, based on listening data.
  *
  * @param	string	$artist	The artist name in question. (Required)
  * @return	array			An array of User objects.
  * @see		User
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function getTopFans($artist)
 {
     $xml = CallerFactory::getDefaultCaller()->call('artist.getTopFans', array('artist' => $artist));
     $fans = array();
     foreach ($xml->children() as $fan) {
         $fans[] = User::fromSimpleXMLElement($fan);
     }
     return $fans;
 }