Passed
Branch master (8dda47)
by Taosikai
28:32 queued 13:47
created

Client   F

Complexity

Total Complexity 45

Size/Duplication

Total Lines 390
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 32

Importance

Changes 0
Metric Value
dl 0
loc 390
rs 3.7614
c 0
b 0
f 0
wmc 45
lcom 1
cbo 32

26 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 3
B login() 0 23 4
A makeQrCodeImage() 0 11 3
B verifyQrCodeStatus() 0 21 5
A getPtWebQQ() 0 12 3
A getVfWebQQ() 0 6 1
A getUinAndPSessionId() 0 11 1
A setCredential() 0 5 1
A getCredential() 0 7 2
A getCookies() 0 4 1
A setHttpClient() 0 4 1
A getHttpClient() 0 4 1
A getGroups() 0 6 1
A getGroupDetail() 0 6 1
A getDiscusses() 0 6 1
A getDiscussDetail() 0 6 1
A getFriends() 0 6 1
A getFriendDetail() 0 6 1
A getFriendQQ() 0 8 1
A getFriendLnick() 0 6 1
A getFriendsOnlineStatus() 0 6 1
A getRecentList() 0 6 1
A getCurrentUserInfo() 0 6 1
A pollMessages() 0 6 1
A sendMessage() 0 12 3
A sendRequest() 0 21 4

How to fix   Complexity   

Complex Class

Complex classes like Client often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Client, and based on these observations, apply Extract Interface, too.

1
<?php
2
/**
3
 * SmartQQ Library
4
 * @author Tao <[email protected]>
5
 */
6
namespace Slince\SmartQQ;
7
8
use GuzzleHttp\Client as HttpClient;
9
use GuzzleHttp\Cookie\CookieJar;
10
use GuzzleHttp\Psr7\Request;
11
use Psr\Http\Message\ResponseInterface;
12
use Slince\SmartQQ\Entity\Discuss;
13
use Slince\SmartQQ\Entity\DiscussDetail;
14
use Slince\SmartQQ\Entity\Friend;
15
use Slince\SmartQQ\Entity\Group;
16
use Slince\SmartQQ\Entity\GroupDetail;
17
use Slince\SmartQQ\Entity\Profile;
18
use Slince\SmartQQ\Exception\InvalidArgumentException;
19
use Slince\SmartQQ\Exception\RuntimeException;
20
use Slince\SmartQQ\Message\Request\FriendMessage;
21
use Slince\SmartQQ\Message\Request\GroupMessage;
22
use Slince\SmartQQ\Message\Request\Message as RequestMessage;
23
use Slince\SmartQQ\Message\Response\Message as ResponseMessage;
24
use Slince\SmartQQ\Request\GetLnickRequest;
25
use Slince\SmartQQ\Request\RequestInterface;
26
use Slince\SmartQQ\Request\GetCurrentUserRequest;
27
use Slince\SmartQQ\Request\GetDiscussDetailRequest;
28
use Slince\SmartQQ\Request\GetDiscussesRequest;
29
use Slince\SmartQQ\Request\GetFriendDetailRequest;
30
use Slince\SmartQQ\Request\GetFriendsOnlineStatusRequest;
31
use Slince\SmartQQ\Request\GetFriendsRequest;
32
use Slince\SmartQQ\Request\GetGroupDetailRequest;
33
use Slince\SmartQQ\Request\GetGroupsRequest;
34
use Slince\SmartQQ\Request\GetPtWebQQRequest;
35
use Slince\SmartQQ\Request\GetQQRequest;
36
use Slince\SmartQQ\Request\GetQrCodeRequest;
37
use Slince\SmartQQ\Request\GetRecentListRequest;
38
use Slince\SmartQQ\Request\GetUinAndPsessionidRequest;
39
use Slince\SmartQQ\Request\GetVfWebQQRequest;
40
use Slince\SmartQQ\Request\PollMessagesRequest;
41
use Slince\SmartQQ\Request\SendDiscusMessageRequest;
42
use Slince\SmartQQ\Request\SendFriendMessageRequest;
43
use Slince\SmartQQ\Request\SendGroupMessageRequest;
44
use Slince\SmartQQ\Request\SendMessageRequest;
45
use Slince\SmartQQ\Request\VerifyQrCodeRequest;
46
47
class Client
48
{
49
    /**
50
     * @var Credential
51
     */
52
    protected $credential;
53
54
    /**
55
     * 客户端id(固定值)
56
     * @var int
57
     */
58
    protected static $clientId = 53999199;
59
60
    /**
61
     * 获取ptwebqq的地址
62
     * @var string
63
     */
64
    protected $certificationUrl;
65
66
    /**
67
     * @var HttpClient
68
     */
69
    protected $httpClient;
70
71
    /**
72
     * @var CookieJar
73
     */
74
    protected $cookies;
75
76
    public function __construct(Credential $credential = null, HttpClient $httpClient = null)
77
    {
78
        if (!is_null($credential)) {
79
            $this->setCredential($credential);
80
        }
81
        if (is_null($httpClient)) {
82
            $httpClient = new HttpClient([
83
                'verify' => false
84
            ]);
85
        }
86
        $this->httpClient = $httpClient;
87
    }
88
89
    /**
90
     * 开启登录流程自行获取凭证
91
     * @param string $loginQRImage 二维码图片位置
92
     * @return Credential
93
     */
94
    public function login($loginQRImage)
95
    {
96
        //如果登录则重置cookie
97
        $this->cookies = new CookieJar();
98
        $qrSign = $this->makeQrCodeImage($loginQRImage);
99
        $ptQrToken = Utils::hash33($qrSign);
100
        while (true) {
101
            $status = $this->verifyQrCodeStatus($ptQrToken);
102
            if ($status == VerifyQrCodeRequest::STATUS_EXPIRED) {
103
                $qrSign = $this->makeQrCodeImage($loginQRImage);
104
                $ptQrToken = Utils::hash33($qrSign);
105
            } elseif ($status == VerifyQrCodeRequest::STATUS_CERTIFICATION) {
106
                //授权成功跳出状态检查
107
                break;
108
            }
109
            sleep(1);
110
        }
111
        $ptWebQQ = $this->getPtWebQQ($this->certificationUrl);
112
        $vfWebQQ = $this->getVfWebQQ($ptWebQQ);
113
        list($uin, $pSessionId) = $this->getUinAndPSessionId($ptWebQQ);
114
        $this->credential = new Credential($ptWebQQ, $vfWebQQ, $pSessionId, $uin, static::$clientId, $this->cookies);
115
        return $this->credential;
116
    }
117
118
    /**
119
     * 创建登录所需的二维码
120
     * @param string $loginQRImage
121
     * @return string
122
     */
123
    protected function makeQrCodeImage($loginQRImage)
124
    {
125
        $response = $this->sendRequest(new GetQrCodeRequest());
126
        Utils::getFilesystem()->dumpFile($loginQRImage, $response->getBody());
127
        foreach ($this->getCookies() as $cookie) {
128
            if (strcasecmp($cookie->getName(), 'qrsig') == 0) {
129
                return $cookie->getValue();
130
            }
131
        }
132
        throw new RuntimeException("Can not find parameter [qrsig]");
133
    }
134
135
    /**
136
     * 验证二维码状态
137
     * @param int $ptQrToken qr token
138
     * @return int
139
     */
140
    protected function verifyQrCodeStatus($ptQrToken)
141
    {
142
        $request = new VerifyQrCodeRequest($ptQrToken);
143
        $response = $this->sendRequest($request);
144
        if (strpos($response->getBody(), '未失效') !== false) {
145
            $status = VerifyQrCodeRequest::STATUS_UNEXPIRED;
146
        } elseif (strpos($response->getBody(), '已失效') !== false) {
147
            $status = VerifyQrCodeRequest::STATUS_EXPIRED;
148
        } elseif (strpos($response->getBody(), '认证中') !== false) {
149
            $status = VerifyQrCodeRequest::STATUS_ACCREDITATION;
150
        } else {
151
            $status = VerifyQrCodeRequest::STATUS_CERTIFICATION;
152
            //找出认证url
153
            if (preg_match("#'(http.+)'#U", strval($response->getBody()), $matches)) {
154
                $this->certificationUrl = trim($matches[1]);
155
            } else {
156
                throw new RuntimeException("Can not find certification url");
157
            }
158
        }
159
        return $status;
160
    }
161
162
    /**
163
     * 获取ptwebqq的参数值
164
     * @param string $certificationUrl
165
     * @return string
166
     */
167
    protected function getPtWebQQ($certificationUrl)
168
    {
169
        $request = new GetPtWebQQRequest();
170
        $request->setUri($certificationUrl);
171
        $this->sendRequest($request);
172
        foreach ($this->getCookies() as $cookie) {
173
            if (strcasecmp($cookie->getName(), 'ptwebqq') == 0) {
174
                return $cookie->getValue();
175
            }
176
        }
177
        throw new RuntimeException("Can not find parameter [ptwebqq]");
178
    }
179
180
    /**
181
     * @param string $ptWebQQ
182
     * @return string
183
     */
184
    protected function getVfWebQQ($ptWebQQ)
185
    {
186
        $request = new GetVfWebQQRequest($ptWebQQ);
187
        $response = $this->sendRequest($request);
188
        return GetVfWebQQRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
189
    }
190
191
    /**
192
     * 获取pessionid和uin
193
     * @param string $ptWebQQ
194
     * @return array
195
     */
196
    protected function getUinAndPSessionId($ptWebQQ)
197
    {
198
        $request = new GetUinAndPsessionidRequest([
199
            'ptwebqq' => $ptWebQQ,
200
            'clientid' => static::$clientId,
201
            'psessionid' => '',
202
            'status' => 'online'
203
        ]);
204
        $response = $this->sendRequest($request);
205
        return GetUinAndPsessionidRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
206
    }
207
208
    /**
209
     * @param Credential $credential
210
     */
211
    public function setCredential(Credential $credential)
212
    {
213
        $this->cookies = $credential->getCookies();
214
        $this->credential = $credential;
215
    }
216
217
    /**
218
     * @return Credential
219
     */
220
    public function getCredential()
221
    {
222
        if (!$this->credential) {
223
            throw new InvalidArgumentException("Please login first or set a credential");
224
        }
225
        return $this->credential;
226
    }
227
228
    /**
229
     * @return CookieJar
230
     */
231
    public function getCookies()
232
    {
233
        return $this->cookies;
234
    }
235
236
    /**
237
     * @param HttpClient $httpClient
238
     */
239
    public function setHttpClient($httpClient)
240
    {
241
        $this->httpClient = $httpClient;
242
    }
243
244
    /**
245
     * @return HttpClient
246
     */
247
    public function getHttpClient()
248
    {
249
        return $this->httpClient;
250
    }
251
252
    /**
253
     * 获取所有的群
254
     * @return EntityCollection
255
     */
256
    public function getGroups()
257
    {
258
        $request = new GetGroupsRequest($this->getCredential());
259
        $response = $this->sendRequest($request);
260
        return GetGroupsRequest::parseResponse($response, $this);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
261
    }
262
263
    /**
264
     * 获取群详细信息
265
     * @param Group $group
266
     * @return GroupDetail
267
     */
268
    public function getGroupDetail(Group $group)
269
    {
270
        $request = new GetGroupDetailRequest($group, $this->getCredential());
271
        $response = $this->sendRequest($request);
272
        return GetGroupDetailRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
273
    }
274
275
    /**
276
     * 获取所有讨论组
277
     * @return EntityCollection
278
     */
279
    public function getDiscusses()
280
    {
281
        $request = new GetDiscussesRequest($this->getCredential());
282
        $response = $this->sendRequest($request);
283
        return GetDiscussesRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
284
    }
285
286
    /**
287
     * 获取讨论组详情
288
     * @param Discuss $discuss
289
     * @return DiscussDetail
290
     */
291
    public function getDiscussDetail(Discuss $discuss)
292
    {
293
        $request = new GetDiscussDetailRequest($discuss, $this->getCredential());
294
        $response = $this->sendRequest($request);
295
        return GetDiscussDetailRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
296
    }
297
298
    /**
299
     * 获取所有的好友
300
     * @return EntityCollection
301
     */
302
    public function getFriends()
303
    {
304
        $request = new GetFriendsRequest($this->getCredential());
305
        $response = $this->sendRequest($request);
306
        return GetFriendsRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
307
    }
308
309
    /**
310
     * 获取好友的详细信息
311
     * @param Friend $friend
312
     * @return Profile
313
     */
314
    public function getFriendDetail(Friend $friend)
315
    {
316
        $request = new GetFriendDetailRequest($friend, $this->getCredential());
317
        $response = $this->sendRequest($request);
318
        return GetFriendDetailRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
319
    }
320
321
    /**
322
     * 获取好友的QQ号
323
     * @param Friend $friend
324
     * @return int
325
     */
326
    public function getFriendQQ(Friend $friend)
327
    {
328
        $request = new GetQQRequest($friend, $this->getCredential());
329
        $response = $this->sendRequest($request);
330
        $qq = GetQQRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
331
        $friend->setQq($qq);
332
        return $qq;
333
    }
334
335
    /**
336
     * 获取好友的个性签名
337
     * @param Friend $friend
338
     * @return string
339
     */
340
    public function getFriendLnick(Friend $friend)
341
    {
342
        $request = new GetLnickRequest($friend, $this->getCredential());
343
        $response = $this->sendRequest($request);
344
        return GetLnickRequest::parseResponse($response, $friend);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
345
    }
346
347
    /**
348
     * 获取好友在线状态
349
     * @return EntityCollection
350
     */
351
    public function getFriendsOnlineStatus()
352
    {
353
        $request = new GetFriendsOnlineStatusRequest($this->getCredential());
354
        $response = $this->sendRequest($request);
355
        return GetFriendsOnlineStatusRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
356
    }
357
358
    /**
359
     * 获取最近的会话
360
     * @return EntityCollection
361
     */
362
    public function getRecentList()
363
    {
364
        $request = new GetRecentListRequest($this->getCredential());
365
        $response = $this->sendRequest($request);
366
        return GetRecentListRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
367
    }
368
369
    /**
370
     * 获取当前登录用户信息
371
     * @return Profile
372
     */
373
    public function getCurrentUserInfo()
374
    {
375
        $request = new GetCurrentUserRequest();
376
        $response = $this->sendRequest($request);
377
        return GetCurrentUserRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
378
    }
379
380
    /**
381
     * 轮询消息,
382
     * client并不会组装信息,只是将接口返回的信息完整抽象并返回
383
     * 如果需要查询信息对应的数据,如发送人、发送群,请自行获取
384
     * @return ResponseMessage[]
385
     */
386
    public function pollMessages()
387
    {
388
        $request = new PollMessagesRequest($this->getCredential());
389
        $response = $this->sendRequest($request);
390
        return PollMessagesRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
391
    }
392
393
    /**
394
     * 发送消息,包括好友消息,群消息,讨论组消息
395
     * @param RequestMessage $message
396
     * @return bool
397
     */
398
    public function sendMessage(RequestMessage $message)
399
    {
400
        if ($message instanceof FriendMessage) {
401
            $request = new SendFriendMessageRequest($message, $this->getCredential());
402
        } elseif ($message instanceof GroupMessage) {
403
            $request = new SendGroupMessageRequest($message, $this->getCredential());
404
        } else {
405
            $request = new SendDiscusMessageRequest($message, $this->getCredential());
0 ignored issues
show
Compatibility introduced by
$message of type object<Slince\SmartQQ\Message\Request\Message> is not a sub-type of object<Slince\SmartQQ\Me...Request\DiscussMessage>. It seems like you assume a child class of the class Slince\SmartQQ\Message\Request\Message to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
406
        }
407
        $response = $this->sendRequest($request);
408
        return SendMessageRequest::parseResponse($response);
0 ignored issues
show
Compatibility introduced by
$response of type object<Psr\Http\Message\ResponseInterface> is not a sub-type of object<GuzzleHttp\Psr7\Response>. It seems like you assume a concrete implementation of the interface Psr\Http\Message\ResponseInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
409
    }
410
411
    /**
412
     * @param RequestInterface $request
413
     * @return ResponseInterface
414
     */
415
    protected function sendRequest(RequestInterface $request)
416
    {
417
        $options = [
418
            'cookies' => $this->getCookies()
419
        ];
420
        if ($parameters = $request->getParameters()) {
421
            if ($request->getMethod() == RequestInterface::REQUEST_METHOD_GET) {
422
                $options['query'] = $parameters;
423
            } else {
424
                $options['form_params'] = $parameters;
425
            }
426
        }
427
        //如果有referer需要伪造该信息
428
        if ($referer = $request->getReferer()) {
429
            $options['headers'] = [
430
                'Referer' => $referer
431
            ];
432
        }
433
        $response = $this->httpClient->send(new Request($request->getMethod(), $request->getUri()), $options);
434
        return $response;
435
    }
436
}
437