Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F114251023
PhutilAuthAdapterOAuthTwitter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, May 24, 14:57
Size
1 KB
Mime Type
text/x-php
Expires
Mon, May 26, 14:57 (2 d)
Engine
blob
Format
Raw Data
Handle
26345151
Attached To
rPHU libphutil
PhutilAuthAdapterOAuthTwitter.php
View Options
<?php
/**
* Authentication adapter for Twitter OAuth1.
*/
final
class
PhutilAuthAdapterOAuthTwitter
extends
PhutilAuthAdapterOAuth1
{
private
$userInfo
;
public
function
getAccountID
()
{
return
idx
(
$this
->
getHandshakeData
(),
'user_id'
);
}
public
function
getAccountName
()
{
return
idx
(
$this
->
getHandshakeData
(),
'screen_name'
);
}
public
function
getAccountURI
()
{
$name
=
$this
->
getAccountName
();
if
(
strlen
(
$name
))
{
return
'https://twitter.com/'
.
$name
;
}
return
null
;
}
public
function
getAccountImageURI
()
{
$info
=
$this
->
getUserInfo
();
return
idx
(
$info
,
'profile_image_url'
);
}
public
function
getAccountRealName
()
{
$info
=
$this
->
getUserInfo
();
return
idx
(
$info
,
'name'
);
}
public
function
getAdapterType
()
{
return
'twitter'
;
}
public
function
getAdapterDomain
()
{
return
'twitter.com'
;
}
protected
function
getRequestTokenURI
()
{
return
'https://api.twitter.com/oauth/request_token'
;
}
protected
function
getAuthorizeTokenURI
()
{
return
'https://api.twitter.com/oauth/authorize'
;
}
protected
function
getValidateTokenURI
()
{
return
'https://api.twitter.com/oauth/access_token'
;
}
private
function
getUserInfo
()
{
if
(
$this
->
userInfo
===
null
)
{
$uri
=
new
PhutilURI
(
'https://api.twitter.com/1.1/users/show.json'
);
$uri
->
setQueryParams
(
array
(
'user_id'
=>
$this
->
getAccountID
(),
));
$data
=
$this
->
newOAuth1Future
(
$uri
)
->
setMethod
(
'GET'
)
->
resolveJSON
();
$this
->
userInfo
=
$data
;
}
return
$this
->
userInfo
;
}
}
Event Timeline
Log In to Comment