Source for file Geo.php

Documentation is available at Geo.php

  1. <?
  2.  
  3. /** Provides different methods to query geo based information.
  4.  *
  5.  * @package    php-lastfm-api
  6.  * @author  Felix Bruns <felixbruns@web.de>
  7.  * @version    1.0
  8.  */
  9. class Geo {
  10.     /** Get all events in a specific location by country or city name.
  11.      *
  12.      * @param    string    $location    Specifies a location to retrieve events for (service returns nearby events by default). (Optional)
  13.      * @param    float    $lat        Specifies a latitude value to retrieve events for (service returns nearby events by default). (Optional)
  14.      * @param    float    $long        Specifies a longitude value to retrieve events for (service returns nearby events by default). (Optional)
  15.      * @param    integer    $distance    Find events within a specified distance. (Optional)
  16.      * @param    integer    $page        Display more results by pagination. (Optional)
  17.      * @return    PaginatedResult        A PaginatedResult object.
  18.      *
  19.      * @static
  20.      * @access    public
  21.      * @throws    Error
  22.      */
  23.     public static function getEvents($location null$lat null$long null,
  24.                                      $distance null$page null){
  25.         $xml CallerFactory::getDefaultCaller()->call('geo.getEvents'array(
  26.             'location' => $location,
  27.             'lat'      => $lat,
  28.             'long'     => $long,
  29.             'distance' => $distance,
  30.             'page'     => $page
  31.         ));
  32.  
  33.         $events array();
  34.  
  35.         foreach($xml->children(as $event){
  36.             $events[Event::fromSimpleXMLElement($event);
  37.         }
  38.  
  39.         $perPage intval(ceil(
  40.             Util::toInteger($xml['total']Util::toInteger($xml['totalpages'])
  41.         ));
  42.  
  43.         return new PaginatedResult(
  44.             Util::toInteger($xml['total']),
  45.             (Util::toInteger($xml['page']1$perPage,
  46.             $perPage,
  47.             $events
  48.         );
  49.     }
  50.  
  51.     /** Get the most popular artists on last.fm by country.
  52.      *
  53.      * @param    string    country        A country name, as defined by the ISO 3166-1 country names standard. (Required)
  54.      * @return    array                An array of Artist objects.
  55.      *
  56.      * @static
  57.      * @access    public
  58.      * @throws    Error
  59.      */
  60.     public static function getTopArtists($country){
  61.         $xml CallerFactory::getDefaultCaller()->call('geo.getTopArtists'array(
  62.             'country' => $country
  63.         ));
  64.  
  65.         $artists array();
  66.  
  67.         foreach($xml->children(as $artist){
  68.             $artists[Artist::fromSimpleXMLElement($artist);
  69.         }
  70.  
  71.         return $artists;
  72.     }
  73.  
  74.     /** Get the most popular tracks on last.fm by country.
  75.      *
  76.      * @param    string    country        A country name, as defined by the ISO 3166-1 country names standard. (Required)
  77.      * @param    string    location    A metro name, to fetch the charts for (must be within the country specified). (Optional)
  78.      * @return    array                An array of Track objects.
  79.      *
  80.      * @static
  81.      * @access    public
  82.      * @throws    Error
  83.      */
  84.     public static function getTopTracks($country$location null){
  85.         $xml CallerFactory::getDefaultCaller()->call('geo.getTopTracks'array(
  86.             'country'  => $country,
  87.             'location' => $location
  88.         ));
  89.  
  90.         $tracks array();
  91.  
  92.         foreach($xml->children(as $track){
  93.             $tracks[Track::fromSimpleXMLElement($track);
  94.         }
  95.  
  96.         return $tracks;
  97.     }
  98. }
  99.  
  100. ?>

Documentation generated on Mon, 22 Dec 2008 16:57:37 +0100 by phpDocumentor 1.4.1