5 * @author Galen Grover <galenjr@gmail.com>
6 * @license http://opensource.org/licenses/mit-license.php The MIT License
11 use \Instagram\Collection\MediaCollection;
16 * Some media has a location associated to it. This location will have an ID and a name.
17 * Some media has no location associated, but has a lat/lng. These location objects will return null or '' for certain method calls
19 * @see \Instagram\Instagram->getCurrentUser()
20 * {@link https://github.com/galen/PHP-Instagram-API/blob/master/Examples/location.php}
21 * {@link http://galengrover.com/projects/instagram/?example=location.php}
23 class Location extends \Instagram\Core\BaseObjectAbstract {
28 * Retrieve the recent media posted to a given location
30 * This can be paginated with the next_max_id param obtained from MediaCollection->getNext()
32 * @param array $params Optional params to pass to the endpoint
33 * @return \Instagram\Collection\MediaCollection
36 public function getMedia( array $params = null ) {
37 return new MediaCollection( $this->proxy->getLocationMedia( $this->getApiId(), $params ), $this->proxy );
46 public function getId() {
47 return isset( $this->data->id ) ? $this->data->id : null;
56 public function getName() {
57 return isset( $this->data->name ) ? $this->data->name : null;
61 * Get location longitude
63 * Get the longitude of the location
68 public function getLat() {
69 return isset( $this->data->latitude ) && is_float( $this->data->latitude ) ? $this->data->latitude : null;
73 * Get location latitude
75 * Get the latitude of the location
80 public function getLng() {
81 return isset( $this->data->longitude ) && is_float( $this->data->longitude ) ? $this->data->longitude : null;
85 * Magic toString method
87 * Returns the location's name
92 public function __toString() {
93 return $this->getName() ? $this->getName() : '';