]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/TwitterBridge/twitteroauthclient.php
adding the odd but reported Twitter avatar .jpeg file extension
[quix0rs-gnu-social.git] / plugins / TwitterBridge / twitteroauthclient.php
index 5d10d8f71282efbc4a04f2d9882fae922d6edcea..a17911b03eb062623e9c4bb2e5a807d4938bcd23 100644 (file)
@@ -43,10 +43,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) {
  */
 class TwitterOAuthClient extends OAuthClient
 {
-    public static $requestTokenURL = 'https://twitter.com/oauth/request_token';
-    public static $authorizeURL    = 'https://twitter.com/oauth/authorize';
-    public static $signinUrl       = 'https://twitter.com/oauth/authenticate';
-    public static $accessTokenURL  = 'https://twitter.com/oauth/access_token';
+    public static $requestTokenURL = 'https://api.twitter.com/oauth/request_token';
+    public static $authorizeURL    = 'https://api.twitter.com/oauth/authorize';
+    public static $signinUrl       = 'https://api.twitter.com/oauth/authenticate';
+    public static $accessTokenURL  = 'https://api.twitter.com/oauth/access_token';
 
     /**
      * Constructor
@@ -157,7 +157,7 @@ class TwitterOAuthClient extends OAuthClient
      */
     function verifyCredentials()
     {
-        $url          = 'https://twitter.com/account/verify_credentials.json';
+        $url          = 'https://api.twitter.com/1/account/verify_credentials.json';
         $response     = $this->oAuthGet($url);
         $twitter_user = json_decode($response);
         return $twitter_user;
@@ -175,7 +175,7 @@ class TwitterOAuthClient extends OAuthClient
      */
     function statusesUpdate($status, $params=array())
     {
-        $url      = 'https://twitter.com/statuses/update.json';
+        $url      = 'https://api.twitter.com/1/statuses/update.json';
         if (is_numeric($params)) {
             $params = array('in_reply_to_status_id' => intval($params));
         }
@@ -200,8 +200,7 @@ class TwitterOAuthClient extends OAuthClient
     function statusesHomeTimeline($since_id = null, $max_id = null,
                                   $cnt = null, $page = null)
     {
-
-        $url    = 'https://twitter.com/statuses/home_timeline.json';
+        $url    = 'https://api.twitter.com/1/statuses/home_timeline.json';
 
         $params = array('include_entities' => 'true');
 
@@ -218,13 +217,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;
     }
@@ -242,19 +235,27 @@ class TwitterOAuthClient extends OAuthClient
     function statusesFriends($id = null, $user_id = null, $screen_name = null,
                              $page = null)
     {
-        $url = "https://twitter.com/statuses/friends.json";
+        $url = "https://api.twitter.com/1/statuses/friends.json";
+
+        $params = array();
 
-        $params = array('id' => $id,
-                        'user_id' => $user_id,
-                        'screen_name' => $screen_name,
-                        'page' => $page);
-        $qry    = http_build_query($params);
+        if (!empty($id)) {
+            $params['id'] = $id;
+        }
+
+        if (!empty($user_id)) {
+            $params['user_id'] = $user_id;
+        }
+
+        if (!empty($screen_name)) {
+            $params['screen_name'] = $screen_name;
+        }
 
-        if (!empty($qry)) {
-            $url .= "?$qry";
+        if (!empty($page)) {
+            $params['page'] = $page;
         }
 
-        $response = $this->oAuthGet($url);
+        $response = $this->oAuthGet($url, $params);
         $friends  = json_decode($response);
         return $friends;
     }
@@ -272,19 +273,27 @@ class TwitterOAuthClient extends OAuthClient
     function friendsIds($id = null, $user_id = null, $screen_name = null,
                          $page = null)
     {
-        $url = "https://twitter.com/friends/ids.json";
+        $url = "https://api.twitter.com/1/friends/ids.json";
+
+        $params = array();
+
+        if (!empty($id)) {
+            $params['id'] = $id;
+        }
 
-        $params = array('id' => $id,
-                        'user_id' => $user_id,
-                        'screen_name' => $screen_name,
-                        'page' => $page);
-        $qry    = http_build_query($params);
+        if (!empty($user_id)) {
+            $params['user_id'] = $user_id;
+        }
+
+        if (!empty($screen_name)) {
+            $params['screen_name'] = $screen_name;
+        }
 
-        if (!empty($qry)) {
-            $url .= "?$qry";
+        if (!empty($page)) {
+            $params['page'] = $page;
         }
 
-        $response = $this->oAuthGet($url);
+        $response = $this->oAuthGet($url, $params);
         $ids      = json_decode($response);
         return $ids;
     }