1 | <?php |
||
6 | class Credential implements \ArrayAccess |
||
7 | { |
||
8 | protected $consumer_key; |
||
9 | protected $consumer_secret; |
||
10 | protected $token = ''; |
||
11 | protected $token_secret = ''; |
||
12 | |||
13 | 69 | public function __construct(array $params = []) |
|
22 | |||
23 | public function with(array $params = []) |
||
24 | { |
||
25 | $clone = clone $this; |
||
26 | foreach ($params as $key => $value) { |
||
27 | $this->{CredentialNormalizer::normalizeCredentialParamName($key)} = $value; |
||
28 | } |
||
29 | return $clone; |
||
30 | } |
||
31 | |||
32 | 18 | public function toArray($assoc = false) |
|
37 | |||
38 | 12 | public function offsetGet($offset) |
|
42 | |||
43 | public function offsetSet($offset, $value) |
||
44 | { |
||
45 | throw new \BadMethodCallException('Unsupported operation.'); |
||
46 | } |
||
47 | |||
48 | public function offsetUnset($offset) |
||
49 | { |
||
50 | throw new \BadMethodCallException('Unsupported operation.'); |
||
51 | } |
||
52 | |||
53 | public function offsetExists($offset) |
||
54 | { |
||
55 | return isset($this->$offset); |
||
56 | } |
||
57 | |||
58 | 2 | public function __get($key) |
|
62 | |||
63 | public function __isset($key) |
||
64 | { |
||
65 | return isset($this->{CredentialNormalizer::normalizeCredentialParamName($key)}); |
||
66 | } |
||
67 | |||
68 | 4 | public function getAuthorizeUrl($force_login = false) |
|
76 | |||
77 | public function getAuthenticateUrl($force_login = false) |
||
78 | { |
||
79 | $params = http_build_query([ |
||
80 | 'oauth_token' => $this->token, |
||
81 | 'force_login' => $force_login ? 1 : null, |
||
82 | ], '', '&'); |
||
83 | return 'https://api.twitter.com/oauth/authenticate?' . $params; |
||
84 | } |
||
85 | |||
86 | 46 | public function getOAuthHeaders($url, $method, array $endpoint_params) |
|
99 | |||
100 | 4 | public function getBasicHeaders() |
|
108 | |||
109 | 2 | public function getBearerHeaders() |
|
113 | |||
114 | 6 | public function getOAuthHeadersForOAuthEcho() |
|
123 | |||
124 | 6 | public function getOAuthHeadersForRequestToken($oauth_callback = null) |
|
139 | |||
140 | 4 | public function getOAuthHeadersForAccessToken($oauth_verifier) |
|
154 | |||
155 | 2 | public function getXAuthHeadersForAccessToken($username, $password) |
|
171 | |||
172 | 56 | protected static function buildOAuthHeaders($url, $method, array $oauth_params, array $key_params, array $endpoint_params) |
|
198 | } |
||
199 |