1 | <?php |
||
29 | class Client |
||
30 | { |
||
31 | /** |
||
32 | * @var Credential |
||
33 | */ |
||
34 | protected $credential; |
||
35 | |||
36 | /** |
||
37 | * @var HttpClient |
||
38 | */ |
||
39 | protected $httpClient; |
||
40 | |||
41 | /** |
||
42 | * @var DispatcherInterface |
||
43 | */ |
||
44 | protected $eventDispatcher; |
||
45 | |||
46 | /** |
||
47 | * @var MessageHandler |
||
48 | */ |
||
49 | protected $messageHandler; |
||
50 | |||
51 | public function __construct( |
||
71 | |||
72 | /** |
||
73 | * 开启登录流程自行获取凭证 |
||
74 | * |
||
75 | * @param string|callable $qrCallback 二维码图片位置|或者自定义处理器 |
||
76 | * |
||
77 | * @return Credential |
||
78 | */ |
||
79 | public function login($qrCallback) |
||
99 | |||
100 | /** |
||
101 | * @param Credential $credential |
||
102 | */ |
||
103 | public function setCredential(Credential $credential) |
||
108 | |||
109 | /** |
||
110 | * @return Credential |
||
111 | */ |
||
112 | public function getCredential() |
||
120 | |||
121 | /** |
||
122 | * 设置 http 请求客户端. |
||
123 | * |
||
124 | * @param HttpClient $httpClient |
||
125 | */ |
||
126 | public function setHttpClient($httpClient) |
||
130 | |||
131 | /** |
||
132 | * 获取 http 客户端 |
||
133 | * @return HttpClient |
||
134 | */ |
||
135 | public function getHttpClient() |
||
139 | |||
140 | /** |
||
141 | * 设置事件处理器. |
||
142 | * |
||
143 | * @param DispatcherInterface $eventDispatcher |
||
144 | */ |
||
145 | public function setEventDispatcher($eventDispatcher) |
||
149 | |||
150 | /** |
||
151 | * 获取事件处理器. |
||
152 | * |
||
153 | * @return DispatcherInterface |
||
154 | */ |
||
155 | public function getEventDispatcher() |
||
159 | |||
160 | /** |
||
161 | * 获取所有的群. |
||
162 | * |
||
163 | * @return EntityCollection |
||
164 | */ |
||
165 | public function getGroups() |
||
172 | |||
173 | /** |
||
174 | * 获取群详细信息. |
||
175 | * |
||
176 | * @param Entity\Group $group |
||
177 | * |
||
178 | * @return Entity\GroupDetail |
||
179 | */ |
||
180 | public function getGroupDetail(Entity\Group $group) |
||
187 | |||
188 | /** |
||
189 | * 获取所有讨论组. |
||
190 | * |
||
191 | * @return EntityCollection |
||
192 | */ |
||
193 | public function getDiscusses() |
||
200 | |||
201 | /** |
||
202 | * 获取讨论组详情. |
||
203 | * |
||
204 | * @param Entity\Discuss $discuss |
||
205 | * |
||
206 | * @return Entity\DiscussDetail |
||
207 | */ |
||
208 | public function getDiscussDetail(Entity\Discuss $discuss) |
||
215 | |||
216 | /** |
||
217 | * 获取所有的好友. |
||
218 | * |
||
219 | * @return EntityCollection|Entity\Friend[] |
||
220 | */ |
||
221 | public function getFriends() |
||
228 | |||
229 | /** |
||
230 | * 获取好友的详细信息. |
||
231 | * |
||
232 | * @param Entity\Friend $friend |
||
233 | * |
||
234 | * @return Entity\Profile |
||
235 | */ |
||
236 | public function getFriendDetail(Entity\Friend $friend) |
||
243 | |||
244 | /** |
||
245 | * 获取好友的QQ号. |
||
246 | * |
||
247 | * @param Entity\Friend $friend |
||
248 | * |
||
249 | * @return int |
||
250 | * @deprecated 此接口 Smartqq 官方已经不再提供 |
||
251 | */ |
||
252 | public function getFriendQQ(Entity\Friend $friend) |
||
263 | |||
264 | /** |
||
265 | * 获取好友的个性签名. |
||
266 | * |
||
267 | * @param Entity\Friend $friend |
||
268 | * |
||
269 | * @return string |
||
270 | */ |
||
271 | public function getFriendLnick(Entity\Friend $friend) |
||
278 | |||
279 | /** |
||
280 | * 获取好友在线状态 |
||
281 | * |
||
282 | * @return EntityCollection |
||
283 | */ |
||
284 | public function getFriendsOnlineStatus() |
||
291 | |||
292 | /** |
||
293 | * 获取最近的会话. |
||
294 | * |
||
295 | * @return EntityCollection |
||
296 | */ |
||
297 | public function getRecentList() |
||
304 | |||
305 | /** |
||
306 | * 获取当前登录用户信息. |
||
307 | * |
||
308 | * @return Entity\Profile |
||
309 | */ |
||
310 | public function getCurrentUserInfo() |
||
317 | |||
318 | /** |
||
319 | * 轮询消息, |
||
320 | * client并不会组装信息,只是将接口返回的信息完整抽象并返回 |
||
321 | * 如果需要查询信息对应的数据,如发送人、发送群,请自行获取. |
||
322 | * |
||
323 | * @return ResponseMessage[] |
||
324 | */ |
||
325 | public function pollMessages() |
||
332 | |||
333 | /** |
||
334 | * 获取 Message handler. |
||
335 | * |
||
336 | * @return MessageHandler |
||
337 | */ |
||
338 | public function getMessageHandler() |
||
345 | |||
346 | /** |
||
347 | * 发送消息,包括好友消息,群消息,讨论组消息. |
||
348 | * |
||
349 | * @param RequestMessage $message |
||
350 | * |
||
351 | * @return bool |
||
352 | */ |
||
353 | public function sendMessage(RequestMessage $message) |
||
366 | |||
367 | |||
368 | /** |
||
369 | * 发送请求 |
||
370 | * |
||
371 | * @param Request\RequestInterface $request |
||
372 | * @param array $options |
||
373 | * @return HttpResponse |
||
374 | */ |
||
375 | public function sendRequest(Request\RequestInterface $request, array $options = []) |
||
400 | } |
||
401 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: