1 | <?php |
||
9 | trait AuthenticatorTrait |
||
10 | { |
||
11 | abstract public function withCredentials(array $credentails); |
||
14 | |||
15 | 1 | public function oauthForRequestTokenAsync($oauth_callback = null) |
|
16 | 1 | { |
|
17 | 1 | $obj = (yield ResponseYielder::asyncExecDecoded($this->getInternalCurl()->oauthForRequestToken($oauth_callback))); |
|
18 | 1 | yield CoInterface::RETURN_WITH => $this->withCredentials([ |
|
19 | 1 | $this->getInternalCredential()['consumer_key'], |
|
20 | 1 | $this->getInternalCredential()['consumer_secret'], |
|
21 | 1 | $obj->oauth_token, |
|
22 | 1 | $obj->oauth_token_secret, |
|
23 | ]); |
||
24 | } |
||
25 | |||
26 | 1 | public function oauthForAccessTokenAsync($oauth_verifier) |
|
27 | 1 | { |
|
28 | 1 | $obj = (yield ResponseYielder::asyncExecDecoded($this->getInternalCurl()->oauthForAccessToken($oauth_verifier))); |
|
29 | 1 | yield CoInterface::RETURN_WITH => $this->withCredentials([ |
|
30 | 1 | $this->getInternalCredential()['consumer_key'], |
|
31 | 1 | $this->getInternalCredential()['consumer_secret'], |
|
32 | 1 | $obj->oauth_token, |
|
33 | 1 | $obj->oauth_token_secret, |
|
34 | ]); |
||
35 | } |
||
36 | |||
37 | 1 | public function xauthForAccessTokenAsync($username, $password) |
|
38 | 1 | { |
|
39 | 1 | $obj = (yield ResponseYielder::asyncExecDecoded($this->getInternalCurl()->xauthForAccessToken($username, $password))); |
|
40 | 1 | yield CoInterface::RETURN_WITH => $this->withCredentials([ |
|
41 | 1 | $this->getInternalCredential()['consumer_key'], |
|
42 | 1 | $this->getInternalCredential()['consumer_secret'], |
|
43 | 1 | $obj->oauth_token, |
|
44 | 1 | $obj->oauth_token_secret, |
|
45 | ]); |
||
46 | } |
||
47 | |||
48 | 1 | public function oauthForRequestToken($oauth_callback = null) |
|
49 | 1 | { |
|
50 | 1 | $obj = ResponseYielder::syncExecDecoded($this->getInternalCurl()->oauthForRequestToken($oauth_callback)); |
|
51 | 1 | return $this->withCredentials([ |
|
52 | 1 | $this->getInternalCredential()['consumer_key'], |
|
53 | 1 | $this->getInternalCredential()['consumer_secret'], |
|
54 | 1 | $obj->oauth_token, |
|
55 | 1 | $obj->oauth_token_secret, |
|
56 | ]); |
||
57 | } |
||
58 | |||
59 | 1 | public function oauthForAccessToken($oauth_verifier) |
|
60 | 1 | { |
|
61 | 1 | $obj = ResponseYielder::syncExecDecoded($this->getInternalCurl()->oauthForAccessToken($oauth_verifier)); |
|
62 | 1 | return $this->withCredentials([ |
|
63 | 1 | $this->getInternalCredential()['consumer_key'], |
|
64 | 1 | $this->getInternalCredential()['consumer_secret'], |
|
65 | 1 | $obj->oauth_token, |
|
66 | 1 | $obj->oauth_token_secret, |
|
67 | ]); |
||
68 | } |
||
69 | |||
70 | 1 | public function xauthForAccessToken($username, $password) |
|
71 | 1 | { |
|
72 | 1 | $obj = ResponseYielder::syncExecDecoded($this->getInternalCurl()->xauthForAccessToken($username, $password)); |
|
73 | 1 | return $this->withCredentials([ |
|
74 | 1 | $this->getInternalCredential()['consumer_key'], |
|
75 | 1 | $this->getInternalCredential()['consumer_secret'], |
|
76 | 1 | $obj->oauth_token, |
|
77 | 1 | $obj->oauth_token_secret, |
|
78 | ]); |
||
79 | } |
||
80 | |||
81 | public function loginAsync($username, $password) |
||
102 | |||
103 | public function login($username, $password) |
||
124 | } |
||
125 |