Version 1
[yaffs-website] / vendor / php-instagram-api / php-instagram-api / Instagram / Tag.php
1 <?php
2
3 /**
4 * Instagram PHP
5 * @author Galen Grover <galenjr@gmail.com>
6 * @license http://opensource.org/licenses/mit-license.php The MIT License
7 */
8
9 namespace Instagram;
10
11 use \Instagram\Collection\TagMediaCollection;
12
13 /**
14  * Tag class
15  *
16  * @see \Instagram\Instagram->getTag()
17  * {@link https://github.com/galen/PHP-Instagram-API/blob/master/Examples/tag.php}
18  * {@link http://galengrover.com/projects/instagram/?example=tag.php}
19  */
20 class Tag extends \Instagram\Core\BaseObjectAbstract {
21
22     /**
23      * Get tag media
24      *
25      * Retrieve the recent media posted with this tag
26      *
27      * This can be paginated with the next_max_id param obtained from MediaCollection->getNext()
28      *
29      * @param array $params Optional params to pass to the endpoint
30      * @return \Instagram\Collection\MediaCollection
31      * @access public
32      */
33     public function getMedia( array $params = null ) {
34         return new TagMediaCollection( $this->proxy->getTagMedia( $this->getApiId(), $params ), $this->proxy );
35     }
36
37     /**
38      * Get media count
39      *
40      * @return int
41      * @access public
42      */
43     public function getMediaCount() {
44         return (int)$this->data->media_count;
45     }
46
47     /**
48      * Get tag name
49      *
50      * @return string
51      * @access public
52      */
53     public function getName() {
54         return $this->data->name;
55     }
56
57     /**
58      * Get ID
59      *
60      * The ID for a tag is it's name, so return the name
61      *
62      * @return string
63      * @access public
64      */
65     public function getId() {
66         return $this->getName();
67     }
68
69     /**
70      * Magic toString method
71      *
72      * Return the tag name
73      *
74      * @return string
75      * @access public
76      */
77     public function __toString() {
78         return $this->getName();
79     }
80
81 }