当前位置: 首页>>代码示例>>PHP>>正文


PHP Track::fromSimpleXMLElement方法代码示例

本文整理汇总了PHP中Track::fromSimpleXMLElement方法的典型用法代码示例。如果您正苦于以下问题:PHP Track::fromSimpleXMLElement方法的具体用法?PHP Track::fromSimpleXMLElement怎么用?PHP Track::fromSimpleXMLElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Track的用法示例。


在下文中一共展示了Track::fromSimpleXMLElement方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTopTracks

 /** Get the most popular tracks on last.fm by country.
  *
  * @param	string	country		A country name, as defined by the ISO 3166-1 country names standard. (Required)
  * @param	string	location	A metro name, to fetch the charts for (must be within the country specified). (Optional)
  * @return	array				An array of Track objects.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function getTopTracks($country, $location = null)
 {
     $xml = CallerFactory::getDefaultCaller()->call('geo.getTopTracks', array('country' => $country, 'location' => $location));
     $tracks = array();
     foreach ($xml->children() as $track) {
         $tracks[] = Track::fromSimpleXMLElement($track);
     }
     return $tracks;
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:19,代码来源:Geo.php

示例2: getTracks

 /** A paginated list of all the tracks in a user's library, with play counts and tag counts.
  *
  * @param	string	$user	The user whose library you want to fetch. (Required)
  * @param	integer	$limit	Limit the amount of tracks returned (maximum/default is 50). (Optional)
  * @param	integer	$page	The page number you wish to scan to. (Optional)
  * @return	PaginatedResult	A PaginatedResult object.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function getTracks($user, $limit, $page)
 {
     $xml = CallerFactory::getDefaultCaller()->call('library.getTracks', array('user' => $user, 'limit' => $limit, 'page' => $page));
     $tracks = array();
     foreach ($xml->children() as $track) {
         $tracks[] = Track::fromSimpleXMLElement($track);
     }
     $perPage = Util::toInteger($xml['perPage']);
     return new PaginatedResult(Util::toInteger($xml['totalPages']) * $perPage, (Util::toInteger($xml['page']) - 1) * $perPage, $perPage, $tracks);
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:21,代码来源:Library.php

示例3: getWeeklyTrackChart

 /** Get a track chart for a group, for a given date range. If no date range is supplied, it will return the most recent album chart for this group.
  *
  * @param	string	$group	The last.fm group name to fetch the charts of. (Required)
  * @param	integer	$from	The date at which the chart should start from. See {@link de.felixbruns.lastfm.Group#getWeeklyChartList Group::getWeeklyChartList} for more. (Optional)
  * @param	integer	$to		The date at which the chart should end on. See {@link de.felixbruns.lastfm.Group#getWeeklyChartList Group::getWeeklyChartList} for more. (Optional)
  * @return	array			An array of Track objects.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function getWeeklyTrackChart($group, $from = null, $to = null)
 {
     $xml = CallerFactory::getDefaultCaller()->call('group.getWeeklyTrackChart', array('group' => $group, 'from' => $from, 'to' => $to));
     $tracks = array();
     foreach ($xml->children() as $track) {
         $tracks[] = Track::fromSimpleXMLElement($track);
     }
     return $tracks;
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:20,代码来源:Group.php

示例4: fromSimpleXMLElement

 /** Create a User object from a SimpleXMLElement.
  *
  * @param	SimpleXMLElement	$xml	A SimpleXMLElement.
  * @return	User						A User object.
  *
  * @static
  * @access	public
  * @internal
  */
 public static function fromSimpleXMLElement(SimpleXMLElement $xml)
 {
     $images = array();
     foreach ($xml->image as $image) {
         $images[Util::toImageType($image['size'])] = Util::toString($image);
     }
     return new User(Util::toString($xml->name), Util::toString($xml->realname), Util::toString($xml->url), Util::toString($xml->lang), Util::toString($xml->country), Util::toInteger($xml->age), Util::toString($xml->gender), Util::toInteger($xml->subscriber), Util::toInteger($xml->playcount), Util::toInteger($xml->playlists), $images, $xml->recenttrack ? Track::fromSimpleXMLElement($xml->recenttrack) : null, Util::toFloat($xml->match), Util::toInteger($xml->weight), Util::toInteger($xml->registered['unixtime']));
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:17,代码来源:User.php

示例5: search

 /** Search for a track by track name. Returns track matches sorted by relevance.
  *
  * @param	string	$track	The track name in question. (Required)
  * @param	string	$artist	Narrow your search by specifying an artist. (Optional)
  * @param	integer	$limit	Limit the number of tracks returned at one time. Default (maximum) is 30. (Optional)
  * @param	integer	$page	Scan into the results by specifying a page number. Defaults to first page. (Optional)
  * @return	PaginatedResult	A PaginatedResult object.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function search($track, $artist = null, $limit = null, $page = null)
 {
     $xml = CallerFactory::getDefaultCaller()->call('track.search', array('artist' => $artist, 'track' => $track, 'limit' => $limit, 'page' => $page));
     $tracks = array();
     foreach ($xml->trackmatches->children() as $track) {
         $tracks[] = Track::fromSimpleXMLElement($track);
     }
     $opensearch = $xml->children('http://a9.com/-/spec/opensearch/1.1/');
     return new PaginatedResult(Util::toInteger($opensearch->totalResults), Util::toInteger($opensearch->startIndex), Util::toInteger($opensearch->itemsPerPage), $tracks);
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:22,代码来源:Track.php

示例6: getTopTracks

 /** Get the top tracks tagged by this tag, ordered by tag count.
  *
  * @param	string	$tag	The tag name in question. (Required)
  * @return	array			An array of Track objects.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function getTopTracks($tag)
 {
     $xml = CallerFactory::getDefaultCaller()->call('tag.getTopTracks', array('tag' => $tag));
     $tracks = array();
     foreach ($xml->children() as $track) {
         $tracks[] = Track::fromSimpleXMLElement($track);
     }
     return $tracks;
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:18,代码来源:Tag.php

示例7: fromSimpleXMLElement

 /** Create a Playlist object from a SimpleXMLElement.
  *
  * @param SimpleXMLElement  $xml  A SimpleXMLElement object.
  * @return  Playlist          A Playlist object.
  *
  * @static
  * @access  public
  * @internal
  */
 public static function fromSimpleXMLElement(SimpleXMLElement $xml)
 {
     $tracks = array();
     if (isset($xml->trackList)) {
         foreach ($xml->trackList->children() as $track) {
             $tracks[] = Track::fromSimpleXMLElement($track);
         }
     }
     return new Playlist(Util::toInteger($xml->id), Util::toString($xml->title), Util::toString($xml->description), Util::toTimestamp($xml->date), Util::toInteger($xml->size), Util::toInteger($xml->duration), Util::toInteger($xml->streamable), Util::toString($xml->creator), Util::toString($xml->url), $tracks);
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:19,代码来源:Playlist.php


注:本文中的Track::fromSimpleXMLElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。