|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* SocialConnect project |
|
4
|
|
|
* @author: Patsura Dmitry https://github.com/ovr <[email protected]> |
|
5
|
|
|
*/ |
|
6
|
|
|
declare(strict_types=1); |
|
7
|
|
|
|
|
8
|
|
|
namespace SocialConnect\OAuth2\Provider; |
|
9
|
|
|
|
|
10
|
|
|
use SocialConnect\Common\ArrayHydrator; |
|
11
|
|
|
use SocialConnect\Provider\AccessTokenInterface; |
|
12
|
|
|
use SocialConnect\Provider\Consumer; |
|
13
|
|
|
use SocialConnect\Common\Entity\User; |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @link https://apiok.ru/dev |
|
17
|
|
|
*/ |
|
18
|
|
|
class Odnoklassniki extends \SocialConnect\OAuth2\AbstractProvider |
|
19
|
|
|
{ |
|
20
|
|
|
const NAME = 'odnoklassniki'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* {@inheritdoc} |
|
24
|
|
|
*/ |
|
25
|
3 |
|
public function getBaseUri() |
|
26
|
|
|
{ |
|
27
|
3 |
|
return 'https://api.ok.ru/api/'; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* {@inheritdoc} |
|
32
|
|
|
*/ |
|
33
|
2 |
|
public function getAuthorizeUri() |
|
34
|
|
|
{ |
|
35
|
2 |
|
return 'http://connect.ok.ru/oauth/authorize'; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* {@inheritdoc} |
|
40
|
|
|
*/ |
|
41
|
2 |
|
public function getRequestTokenUri() |
|
42
|
|
|
{ |
|
43
|
2 |
|
return 'http://api.odnoklassniki.ru/oauth/token.do'; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* {@inheritdoc} |
|
48
|
|
|
*/ |
|
49
|
3 |
|
public function getName() |
|
50
|
|
|
{ |
|
51
|
3 |
|
return self::NAME; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @link https://apiok.ru/dev/methods/ |
|
56
|
|
|
* |
|
57
|
|
|
* @param array $requestParameters |
|
58
|
|
|
* @param AccessTokenInterface $accessToken |
|
59
|
|
|
* @return string |
|
60
|
|
|
*/ |
|
61
|
2 |
|
protected function makeSecureSignature(array $requestParameters, AccessTokenInterface $accessToken) |
|
62
|
|
|
{ |
|
63
|
2 |
|
ksort($requestParameters); |
|
64
|
|
|
|
|
65
|
2 |
|
$params = ''; |
|
66
|
|
|
|
|
67
|
2 |
|
foreach ($requestParameters as $key => $value) { |
|
68
|
2 |
|
if ($key === 'access_token') { |
|
69
|
2 |
|
continue; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
2 |
|
$params .= "$key=$value"; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
2 |
|
return strtolower(md5($params . md5($accessToken->getToken() . $this->consumer->getSecret()))); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* {@inheritdoc} |
|
80
|
|
|
*/ |
|
81
|
2 |
|
public function getIdentity(AccessTokenInterface $accessToken) |
|
82
|
|
|
{ |
|
83
|
|
|
$parameters = [ |
|
84
|
2 |
|
'application_key' => $this->consumer->getPublic(), |
|
85
|
2 |
|
'access_token' => $accessToken->getToken(), |
|
86
|
2 |
|
'format' => 'json' |
|
87
|
|
|
]; |
|
88
|
|
|
|
|
89
|
2 |
|
$parameters['sig'] = $this->makeSecureSignature($parameters, $accessToken); |
|
90
|
|
|
|
|
91
|
2 |
|
$response = $this->request('GET', 'users/getCurrentUser', [], $accessToken); |
|
92
|
|
|
|
|
93
|
|
|
$hydrator = new ArrayHydrator([ |
|
94
|
|
|
'uid' => 'id', |
|
95
|
|
|
'first_name' => 'firstname', |
|
96
|
|
|
'last_name' => 'lastname', |
|
97
|
|
|
'name' => 'fullname', |
|
98
|
|
|
'pic_3' => 'pictureURL' |
|
99
|
|
|
]); |
|
100
|
|
|
|
|
101
|
|
|
return $hydrator->hydrate(new User(), $response); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
/** |
|
105
|
|
|
* {@inheritDoc} |
|
106
|
|
|
*/ |
|
107
|
14 |
|
protected function createConsumer(array $parameters): Consumer |
|
108
|
|
|
{ |
|
109
|
14 |
|
$consumer = parent::createConsumer($parameters); |
|
110
|
14 |
|
$consumer->setPublic( |
|
111
|
14 |
|
$this->getRequiredStringParameter('applicationPublic', $parameters) |
|
112
|
|
|
); |
|
113
|
|
|
|
|
114
|
14 |
|
return $consumer; |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths