better handling of params in oauthget

This commit is contained in:
Evan Prodromou 2010-09-05 01:49:49 -04:00
parent a844aaaea6
commit 28fecf70b9

View File

@ -218,13 +218,7 @@ class TwitterOAuthClient extends OAuthClient
$params['page'] = $page; $params['page'] = $page;
} }
$qry = http_build_query($params); $response = $this->oAuthGet($url, $params);
if (!empty($qry)) {
$url .= "?$qry";
}
$response = $this->oAuthGet($url);
$statuses = json_decode($response); $statuses = json_decode($response);
return $statuses; return $statuses;
} }
@ -244,17 +238,25 @@ class TwitterOAuthClient extends OAuthClient
{ {
$url = "https://twitter.com/statuses/friends.json"; $url = "https://twitter.com/statuses/friends.json";
$params = array('id' => $id, $params = array();
'user_id' => $user_id,
'screen_name' => $screen_name,
'page' => $page);
$qry = http_build_query($params);
if (!empty($qry)) { if (!empty($id)) {
$url .= "?$qry"; $params['id'] = $id;
} }
$response = $this->oAuthGet($url); if (!empty($user_id)) {
$params['user_id'] = $user_id;
}
if (!empty($screen_name)) {
$params['screen_name'] = $screen_name;
}
if (!empty($page)) {
$params['page'] = $page;
}
$response = $this->oAuthGet($url, $params);
$friends = json_decode($response); $friends = json_decode($response);
return $friends; return $friends;
} }
@ -274,17 +276,25 @@ class TwitterOAuthClient extends OAuthClient
{ {
$url = "https://twitter.com/friends/ids.json"; $url = "https://twitter.com/friends/ids.json";
$params = array('id' => $id, $params = array();
'user_id' => $user_id,
'screen_name' => $screen_name,
'page' => $page);
$qry = http_build_query($params);
if (!empty($qry)) { if (!empty($id)) {
$url .= "?$qry"; $params['id'] = $id;
} }
$response = $this->oAuthGet($url); if (!empty($user_id)) {
$params['user_id'] = $user_id;
}
if (!empty($screen_name)) {
$params['screen_name'] = $screen_name;
}
if (!empty($page)) {
$params['page'] = $page;
}
$response = $this->oAuthGet($url, $params);
$ids = json_decode($response); $ids = json_decode($response);
return $ids; return $ids;
} }