Handle the ways Twitter accepts passing the user in the query string.
This commit is contained in:
parent
9e16b7d89b
commit
6658e2a2ee
@ -144,8 +144,8 @@ class ApiAction extends Action
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($fullname, $bareauth)) {
|
if (in_array($fullname, $bareauth)) {
|
||||||
# bareauth: only needs auth if without an argument
|
# bareauth: only needs auth if without an argument or query param specifying user
|
||||||
if ($this->api_arg) {
|
if ($this->api_arg || $this->arg('id') || is_numeric($this->arg('user_id')) || $this->arg('screen_name')) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@ -673,7 +673,27 @@ class TwitterapiAction extends Action
|
|||||||
function get_user($id, $apidata=null)
|
function get_user($id, $apidata=null)
|
||||||
{
|
{
|
||||||
if (!$id) {
|
if (!$id) {
|
||||||
|
|
||||||
|
// Twitter supports these other ways of passing the user ID
|
||||||
|
if (is_numeric($this->arg('id'))) {
|
||||||
|
return User::staticGet($this->arg('id'));
|
||||||
|
} else if ($this->arg('id')) {
|
||||||
|
$nickname = common_canonical_nickname($this->arg('id'));
|
||||||
|
return User::staticGet('nickname', $nickname);
|
||||||
|
} else if ($this->arg('user_id')) {
|
||||||
|
// This is to ensure that a non-numeric user_id still
|
||||||
|
// overrides screen_name even if it doesn't get used
|
||||||
|
if (is_numeric($this->arg('user_id'))) {
|
||||||
|
return User::staticGet('id', $this->arg('user_id'));
|
||||||
|
}
|
||||||
|
} else if ($this->arg('screen_name')) {
|
||||||
|
$nickname = common_canonical_nickname($this->arg('screen_name'));
|
||||||
|
return User::staticGet('nickname', $nickname);
|
||||||
|
} else {
|
||||||
|
// Fall back to trying the currently authenticated user
|
||||||
return $apidata['user'];
|
return $apidata['user'];
|
||||||
|
}
|
||||||
|
|
||||||
} else if (is_numeric($id)) {
|
} else if (is_numeric($id)) {
|
||||||
return User::staticGet($id);
|
return User::staticGet($id);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user