1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OAuth\OAuth1\Service; |
4
|
|
|
|
5
|
|
|
use OAuth\OAuth1\Signature\SignatureInterface; |
6
|
|
|
use OAuth\OAuth1\Token\StdOAuth1Token; |
7
|
|
|
use OAuth\Common\Http\Exception\TokenResponseException; |
8
|
|
|
use OAuth\Common\Http\Uri\Uri; |
9
|
|
|
use OAuth\Common\Consumer\CredentialsInterface; |
10
|
|
|
use OAuth\Common\Http\Uri\UriInterface; |
11
|
|
|
use OAuth\Common\Storage\TokenStorageInterface; |
12
|
|
|
use OAuth\Common\Http\Client\ClientInterface; |
13
|
|
|
use OAuth\Common\Exception\Exception; |
14
|
|
|
|
15
|
|
|
class Twitter extends AbstractService |
16
|
|
|
{ |
17
|
|
|
const ENDPOINT_AUTHENTICATE = "https://api.twitter.com/oauth/authenticate"; |
18
|
|
|
const ENDPOINT_AUTHORIZE = "https://api.twitter.com/oauth/authorize"; |
19
|
|
|
|
20
|
|
|
protected $authorizationEndpoint = self::ENDPOINT_AUTHENTICATE; |
21
|
|
|
|
22
|
|
|
public function __construct( |
23
|
|
|
CredentialsInterface $credentials, |
24
|
|
|
ClientInterface $httpClient, |
25
|
|
|
TokenStorageInterface $storage, |
26
|
|
|
SignatureInterface $signature, |
27
|
|
|
UriInterface $baseApiUri = null |
28
|
|
|
) { |
29
|
|
|
parent::__construct($credentials, $httpClient, $storage, $signature, $baseApiUri); |
30
|
|
|
|
31
|
|
|
if (null === $baseApiUri) { |
32
|
|
|
$this->baseApiUri = new Uri('https://api.twitter.com/1.1/'); |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritdoc} |
38
|
|
|
*/ |
39
|
|
|
public function getRequestTokenEndpoint() |
40
|
|
|
{ |
41
|
|
|
return new Uri('https://api.twitter.com/oauth/request_token'); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
47
|
|
|
public function getAuthorizationEndpoint() |
48
|
|
|
{ |
49
|
|
|
if ($this->authorizationEndpoint != self::ENDPOINT_AUTHENTICATE |
50
|
|
|
&& $this->authorizationEndpoint != self::ENDPOINT_AUTHORIZE) { |
51
|
|
|
$this->authorizationEndpoint = self::ENDPOINT_AUTHENTICATE; |
52
|
|
|
} |
53
|
|
|
return new Uri($this->authorizationEndpoint); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param string $authorizationEndpoint |
|
|
|
|
58
|
|
|
* |
59
|
|
|
* @throws Exception |
60
|
|
|
*/ |
61
|
|
|
public function setAuthorizationEndpoint($endpoint) |
62
|
|
|
{ |
63
|
|
|
if ($endpoint != self::ENDPOINT_AUTHENTICATE && $endpoint != self::ENDPOINT_AUTHORIZE) { |
64
|
|
|
throw new Exception( |
65
|
|
|
sprintf("'%s' is not a correct Twitter authorization endpoint.", $endpoint) |
66
|
|
|
); |
67
|
|
|
} |
68
|
|
|
$this->authorizationEndpoint = $endpoint; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* {@inheritdoc} |
73
|
|
|
*/ |
74
|
|
|
public function getAccessTokenEndpoint() |
75
|
|
|
{ |
76
|
|
|
return new Uri('https://api.twitter.com/oauth/access_token'); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
} |
80
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.