]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
better handling of params in oauthget
authorEvan Prodromou <evan@status.net>
Sun, 5 Sep 2010 05:49:49 +0000 (01:49 -0400)
committerEvan Prodromou <evan@status.net>
Tue, 7 Sep 2010 08:00:59 +0000 (04:00 -0400)
plugins/TwitterBridge/twitteroauthclient.php

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