1 | <?php |
||
16 | class Pinners extends Provider |
||
17 | { |
||
18 | use Searchable, Followable, HasFollowers; |
||
19 | |||
20 | protected $loginRequired = [ |
||
21 | 'follow', |
||
22 | 'unFollow', |
||
23 | ]; |
||
24 | |||
25 | /** |
||
26 | * Get user info. |
||
27 | * If username param is not specified, will |
||
28 | * return info for logged user. |
||
29 | * |
||
30 | * @param string $username |
||
31 | * |
||
32 | * @return null|array |
||
33 | */ |
||
34 | public function info($username) |
||
35 | { |
||
36 | $res = $this->paginate($username, UrlHelper::RESOURCE_USER_INFO, "/$username/", 1); |
||
37 | $res = iterator_to_array($res); |
||
38 | |||
39 | return !empty($res) ? $res[0] : null; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Get pinner followers. |
||
44 | * |
||
45 | * @param string $username |
||
46 | * @param int $batchesLimit |
||
47 | * |
||
48 | * @return Iterator |
||
49 | */ |
||
50 | public function followers($username, $batchesLimit = 0) |
||
56 | |||
57 | /** |
||
58 | * Get pinner following other pinners. |
||
59 | * |
||
60 | * @param string $username |
||
61 | * @param int $batchesLimit |
||
62 | * |
||
63 | * @return Iterator |
||
64 | */ |
||
65 | public function following($username, $batchesLimit = 0) |
||
71 | |||
72 | /** |
||
73 | * Get pinner pins. |
||
74 | * |
||
75 | * @param string $username |
||
76 | * @param int $batchesLimit |
||
77 | * |
||
78 | * @return Iterator |
||
79 | */ |
||
80 | public function pins($username, $batchesLimit = 0) |
||
86 | |||
87 | /** |
||
88 | * Login as pinner. |
||
89 | * |
||
90 | * @param string $username |
||
91 | * @param string $password |
||
92 | * |
||
93 | * @throws AuthException |
||
94 | * |
||
95 | * @return bool |
||
96 | */ |
||
97 | public function login($username, $password) |
||
117 | |||
118 | /** |
||
119 | * Validates password and login. |
||
120 | * |
||
121 | * @param string $username |
||
122 | * @param string $password |
||
123 | */ |
||
124 | protected function checkCredentials($username, $password) |
||
130 | |||
131 | /** |
||
132 | * Search scope. |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | protected function getScope() |
||
140 | |||
141 | protected function getEntityIdName() |
||
145 | |||
146 | /** |
||
147 | * Follow resource. |
||
148 | * |
||
149 | * @return string |
||
150 | */ |
||
151 | protected function getFollowUrl() |
||
155 | |||
156 | /** |
||
157 | * UnFollow resource. |
||
158 | * |
||
159 | * @return string |
||
160 | */ |
||
161 | protected function getUnfFollowUrl() |
||
165 | |||
166 | /** |
||
167 | * @param string $username |
||
168 | * @param string $url |
||
169 | * @param string $sourceUrl |
||
170 | * @param int $batchesLimit |
||
171 | * |
||
172 | * @return Iterator |
||
173 | */ |
||
174 | public function paginate($username, $url, $sourceUrl, $batchesLimit) |
||
184 | } |
||
185 |