|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the slince/smartqq package. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Slince <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Slince\SmartQQ\Request; |
|
12
|
|
|
|
|
13
|
|
|
use GuzzleHttp\Psr7\Response; |
|
14
|
|
|
use Slince\SmartQQ\Credential; |
|
15
|
|
|
use Slince\SmartQQ\Entity\Birthday; |
|
16
|
|
|
use Slince\SmartQQ\Entity\Friend; |
|
17
|
|
|
use Slince\SmartQQ\Entity\Profile; |
|
18
|
|
|
use Slince\SmartQQ\EntityFactory; |
|
19
|
|
|
use Slince\SmartQQ\Exception\ResponseException; |
|
20
|
|
|
|
|
21
|
|
|
class GetFriendDetailRequest extends Request |
|
22
|
|
|
{ |
|
23
|
|
|
protected $uri = 'http://s.web2.qq.com/api/get_friend_info2?tuin={uin}&vfwebqq={vfwebqq}&clientid=53999199&psessionid={psessionid}&t=0.1'; |
|
24
|
|
|
|
|
25
|
|
|
protected $referer = 'http://s.web2.qq.com/proxy.html?v=20130916001&callback=1&id=1'; |
|
26
|
|
|
|
|
27
|
|
|
public function __construct(Friend $friend, Credential $credential) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->setTokens([ |
|
30
|
|
|
'uin' => $friend->getUin(), |
|
31
|
|
|
'vfwebqq' => $credential->getVfWebQQ(), |
|
32
|
|
|
'psessionid' => $credential->getPSessionId(), |
|
33
|
|
|
]); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* 解析响应数据. |
|
38
|
|
|
* |
|
39
|
|
|
* @param Response $response |
|
40
|
|
|
* |
|
41
|
|
|
* @return Profile |
|
42
|
|
|
*/ |
|
43
|
|
|
public static function parseResponse(Response $response) |
|
44
|
|
|
{ |
|
45
|
|
|
$jsonData = \GuzzleHttp\json_decode($response->getBody(), true); |
|
46
|
|
|
if ($jsonData && 0 == $jsonData['retcode']) { |
|
47
|
|
|
$profileData = $jsonData['result']; |
|
48
|
|
|
//注意获取好友详情接口并不返回account和lnick |
|
49
|
|
|
return EntityFactory::createEntity(Profile::class, [ |
|
50
|
|
|
'account' => isset($profileData['account']) ? $profileData['account'] : null, |
|
51
|
|
|
'lnick' => isset($profileData['lnick']) ? $profileData['lnick'] : null, |
|
52
|
|
|
'face' => $profileData['face'], |
|
53
|
|
|
'birthday' => Birthday::createFromArray($profileData['birthday']), |
|
54
|
|
|
'occupation' => $profileData['occupation'], |
|
55
|
|
|
'phone' => $profileData['phone'], |
|
56
|
|
|
'allow' => $profileData['allow'], |
|
57
|
|
|
'college' => $profileData['college'], |
|
58
|
|
|
'uin' => $profileData['uin'], |
|
59
|
|
|
'constel' => $profileData['constel'], |
|
60
|
|
|
'blood' => $profileData['blood'], |
|
61
|
|
|
'homepage' => $profileData['homepage'], |
|
62
|
|
|
'stat' => isset($profileData['stat']) ? $profileData['stat'] : null, |
|
63
|
|
|
'vipInfo' => $profileData['vip_info'], |
|
64
|
|
|
'country' => $profileData['country'], |
|
65
|
|
|
'city' => $profileData['city'], |
|
66
|
|
|
'personal' => $profileData['personal'], |
|
67
|
|
|
'nick' => $profileData['nick'], |
|
68
|
|
|
'shengXiao' => $profileData['shengxiao'], |
|
69
|
|
|
'email' => $profileData['email'], |
|
70
|
|
|
'province' => $profileData['province'], |
|
71
|
|
|
'gender' => $profileData['gender'], |
|
72
|
|
|
'mobile' => $profileData['mobile'], |
|
73
|
|
|
]); |
|
74
|
|
|
} |
|
75
|
|
|
throw new ResponseException($jsonData['retcode'], $response); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|