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


PHP Artist::fromSimpleXMLElement方法代码示例

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


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

示例1: getWeeklyArtistChart

 /** Get an artist 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 Artist objects.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function getWeeklyArtistChart($group, $from = null, $to = null)
 {
     $xml = CallerFactory::getDefaultCaller()->call('group.getWeeklyArtistChart', array('group' => $group, 'from' => $from, 'to' => $to));
     $artists = array();
     foreach ($xml->children() as $artist) {
         $artists[] = Artist::fromSimpleXMLElement($artist);
     }
     return $artists;
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:20,代码来源:Group.php

示例2: getTopArtists

 /** Get the most popular artists on last.fm by country.
  *
  * @param	string	country		A country name, as defined by the ISO 3166-1 country names standard. (Required)
  * @return	array				An array of Artist objects.
  *
  * @static
  * @access	public
  * @throws	Error
  */
 public static function getTopArtists($country)
 {
     $xml = CallerFactory::getDefaultCaller()->call('geo.getTopArtists', array('country' => $country));
     $artists = array();
     foreach ($xml->children() as $artist) {
         $artists[] = Artist::fromSimpleXMLElement($artist);
     }
     return $artists;
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:18,代码来源:Geo.php

示例3: compare

 /** 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);
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:36,代码来源:Tasteometer.php

示例4: getArtists

 /** A paginated list of all the artists 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 artists 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 getArtists($user, $limit = null, $page = null)
 {
     $xml = CallerFactory::getDefaultCaller()->call('library.getArtists', array('user' => $user, 'limit' => $limit, 'page' => $page));
     $artists = array();
     foreach ($xml->children() as $artist) {
         $artists[] = Artist::fromSimpleXMLElement($artist);
     }
     $perPage = Util::toInteger($xml['perPage']);
     return new PaginatedResult(Util::toInteger($xml['totalPages']) * $perPage, (Util::toInteger($xml['page']) - 1) * $perPage, $perPage, $artists);
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:21,代码来源:Library.php

示例5: fromSimpleXMLElement

 /** Create an Artist object from a SimpleXMLElement object.
  *
  * @param	SimpleXMLElement	$xml	A SimpleXMLElement object.
  * @return	Artist						An Artist object.
  *
  * @static
  * @access	public
  * @internal
  */
 public static function fromSimpleXMLElement(SimpleXMLElement $xml)
 {
     $images = array();
     $tags = array();
     $similar = array();
     /* NOTE: image, image_small... this sucks! */
     if ($xml->image) {
         if (count($xml->image) > 1) {
             foreach ($xml->image as $image) {
                 $images[Util::toImageType($image['size'])] = Util::toString($image);
             }
         } else {
             $images[Media::IMAGE_LARGE] = Util::toString($image);
         }
     }
     if ($xml->image_small) {
         $images[Media::IMAGE_SMALL] = Util::toString($xml->image_small);
     }
     if ($xml->tags) {
         foreach ($xml->tags->children() as $tag) {
             $tags[] = Tag::fromSimpleXMLElement($tag);
         }
     }
     if ($xml->similar) {
         foreach ($xml->similar->children() as $artist) {
             $similar[] = Artist::fromSimpleXMLElement($artist);
         }
     }
     return new Artist(Util::toString($xml->name), Util::toString($xml->mbid), Util::toString($xml->url), $images, Util::toBoolean($xml->streamable), Util::toInteger($xml->listeners), Util::toInteger($xml->playcount), $tags, $similar, $xml->bio ? Util::toString($xml->bio->summary) : "", Util::toFloat($xml->match));
 }
开发者ID:niczak,项目名称:php-last.fm-api,代码行数:39,代码来源:Artist.php


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