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\OAuth1\Provider; |
9
|
|
|
|
10
|
|
|
use SocialConnect\Common\ArrayHydrator; |
11
|
|
|
use SocialConnect\Provider\AccessTokenInterface; |
12
|
|
|
use SocialConnect\Common\Entity\User; |
|
|
|
|
13
|
|
|
|
14
|
|
|
class Twitter extends \SocialConnect\OAuth1\AbstractProvider |
15
|
|
|
{ |
16
|
|
|
const NAME = 'twitter'; |
17
|
|
|
|
18
|
1 |
|
public function getBaseUri() |
19
|
|
|
{ |
20
|
1 |
|
return 'https://api.twitter.com/1.1/'; |
21
|
|
|
} |
22
|
|
|
|
23
|
1 |
|
public function getAuthorizeUri() |
24
|
|
|
{ |
25
|
1 |
|
return 'https://api.twitter.com/oauth/authenticate'; |
26
|
|
|
} |
27
|
|
|
|
28
|
1 |
|
public function getRequestTokenUri() |
29
|
|
|
{ |
30
|
1 |
|
return 'https://api.twitter.com/oauth/request_token'; |
31
|
|
|
} |
32
|
|
|
|
33
|
1 |
|
public function getRequestTokenAccessUri() |
34
|
|
|
{ |
35
|
1 |
|
return 'https://api.twitter.com/oauth/access_token'; |
36
|
|
|
} |
37
|
|
|
|
38
|
1 |
|
public function getName() |
39
|
|
|
{ |
40
|
1 |
|
return self::NAME; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
|
|
public function getIdentity(AccessTokenInterface $accessToken) |
47
|
|
|
{ |
48
|
|
|
$this->consumerToken = $accessToken; |
|
|
|
|
49
|
|
|
|
50
|
|
|
$result = $this->request( |
51
|
|
|
'GET', |
52
|
|
|
'account/verify_credentials.json', |
53
|
|
|
[ |
54
|
|
|
// String is expected because Twitter is awful |
55
|
|
|
'include_email' => 'true' |
56
|
|
|
], |
57
|
|
|
$accessToken |
58
|
|
|
); |
59
|
|
|
|
60
|
|
|
$hydrator = new ArrayHydrator([ |
61
|
|
|
'id' => 'id', |
62
|
|
|
'name' => 'fullname', |
63
|
|
|
'screen_name' => 'username', |
64
|
|
|
'profile_image_url_https' => 'pictureURL' |
65
|
|
|
]); |
66
|
|
|
|
67
|
|
|
/** @var User $user */ |
68
|
|
|
$user = $hydrator->hydrate(new User(), $result); |
69
|
|
|
|
70
|
|
|
// When set to true email will be returned in the user objects as a string. |
71
|
|
|
// If the user does not have an email address on their account, |
72
|
|
|
// or if the email address is not verified, null will be returned. |
73
|
|
|
$user->emailVerified = true; |
74
|
|
|
|
75
|
|
|
return $user; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
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