4 * Authentication adapter for Twitter OAuth1.
6 final class PhutilTwitterAuthAdapter
extends PhutilOAuth1AuthAdapter
{
10 public function getAccountID() {
11 return idx($this->getHandshakeData(), 'user_id');
14 public function getAccountName() {
15 return idx($this->getHandshakeData(), 'screen_name');
18 public function getAccountURI() {
19 $name = $this->getAccountName();
21 return 'https://twitter.com/'.$name;
26 public function getAccountImageURI() {
27 $info = $this->getUserInfo();
28 return idx($info, 'profile_image_url');
31 public function getAccountRealName() {
32 $info = $this->getUserInfo();
33 return idx($info, 'name');
36 public function getAdapterType() {
40 public function getAdapterDomain() {
44 protected function getRequestTokenURI() {
45 return 'https://api.twitter.com/oauth/request_token';
48 protected function getAuthorizeTokenURI() {
49 return 'https://api.twitter.com/oauth/authorize';
52 protected function getValidateTokenURI() {
53 return 'https://api.twitter.com/oauth/access_token';
56 private function getUserInfo() {
57 if ($this->userInfo
=== null) {
59 'user_id' => $this->getAccountID(),
63 'https://api.twitter.com/1.1/users/show.json',
66 $data = $this->newOAuth1Future($uri)
70 $this->userInfo
= $data;
72 return $this->userInfo
;