5 * @author Galen Grover <galenjr@gmail.com>
6 * @license http://opensource.org/licenses/mit-license.php The MIT License
11 use \Instagram\Collection\MediaCollection;
12 use \Instagram\Collection\UserCollection;
17 * @see \Instagram\Instagram->getUser()
18 * {@link https://github.com/galen/PHP-Instagram-API/blob/master/Examples/user.php}
19 * {@link http://galengrover.com/projects/instagram/?example=user.php}
21 class User extends \Instagram\Core\BaseObjectAbstract {
24 * Get the user's username
29 public function getUserName() {
30 return $this->data->username;
34 * Get the user's full name
39 public function getFullName() {
40 return isset( $this->data->full_name ) ? $this->data->full_name : null;
44 * Get the user's profile picture
49 public function getProfilePicture() {
50 return $this->data->profile_picture;
54 * Get the user's biography
59 public function getBio() {
60 return $this->data->bio;
64 * Get the user's website
69 public function getWebsite() {
70 return $this->data->website;
74 * Get the user's counts
76 * @return StdClass|null
79 public function getCounts() {
80 if ( !$this->isCompleteUser() ) {
83 return isset( $this->data->counts ) ? $this->data->counts : null;
87 * Get the user's following count
92 public function getFollowsCount() {
93 return (int)$this->getCounts()->follows;
97 * Get the user's followers count
102 public function getFollowersCount() {
103 return (int)$this->getCounts()->followed_by;
107 * Get the user's media count
112 public function getMediaCount() {
113 return (int)$this->getCounts()->media;
119 * Sometimes user object are incomplete. For instance when getting a media object's comments
120 * the users associated with the comments won't have all their data
124 public function updateData() {
125 $this->setData( $this->proxy->getUser( $this->getApiId() ) );
129 * Return if the user is complete
131 * @see User::updateData()
136 protected function isCompleteUser() {
137 return isset( $this->data->counts );
141 * Get the user's media
143 * This can be paginated with the next_max_id param obtained from MediaCollection->getNext()
145 * @return\Instagram\Collection\MediaCollection
148 public function getMedia( array $params = null ) {
149 return new MediaCollection( $this->proxy->getUserMedia( $this->getApiId(), $params ), $this->proxy );
153 * Get the users that the user follows
155 * This can be paginated with the next_cursor param obtained from UserCollection->getNext()
157 * @return\Instagram\Collection\UserCollection
160 public function getFollows( array $params = null ) {
161 return new UserCollection( $this->proxy->getUserFollows( $this->getApiId(), $params ), $this->proxy );
165 * Get the user's that follow this user
167 * This can be paginated with the next_cursor param obtained from UserCollection->getNext()
169 * @return\Instagram\Collection\UserCollection
172 public function getFollowers( array $params = null ) {
173 return new UserCollection( $this->proxy->getUserFollowers( $this->getApiId(), $params ), $this->proxy );
177 * Magic toString method
179 * Get the user's username
181 * @return\Instagram\Collection\Collection
184 public function __toString() {
185 return $this->getUserName();