]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/apiaction.php
Use ToSelector choice again.
[quix0rs-gnu-social.git] / lib / apiaction.php
index 24f42e4a4103d55e97709eb9f55c975294f80333..6f2f43ab9cffa4294ae03191ac0637822587929a 100644 (file)
@@ -214,11 +214,11 @@ class ApiAction extends Action
             $user = null;
         }
 
-        $twitter_user['id'] = intval($profile->id);
+        $twitter_user['id'] = $profile->getID();
         $twitter_user['name'] = $profile->getBestName();
-        $twitter_user['screen_name'] = $profile->nickname;
-        $twitter_user['location'] = ($profile->location) ? $profile->location : null;
-        $twitter_user['description'] = ($profile->bio) ? $profile->bio : null;
+        $twitter_user['screen_name'] = $profile->getNickname();
+        $twitter_user['location'] = $profile->location;
+        $twitter_user['description'] = $profile->getDescription();
 
         // TODO: avatar url template (example.com/user/avatar?size={x}x{y})
         $twitter_user['profile_image_url'] = Avatar::urlByProfile($profile, AVATAR_STREAM_SIZE);
@@ -1404,20 +1404,21 @@ class ApiAction extends Action
                 if (self::is_decimal($this->arg('user_id'))) {
                     return Profile::getKV('id', $this->arg('user_id'));
                 }
-            } else if ($this->arg('screen_name')) {
+            } elseif (mb_strlen($this->arg('screen_name')) > 0) {
                 $nickname = common_canonical_nickname($this->arg('screen_name'));
-                $user = User::getKV('nickname', $nickname);
-                return $user instanceof User ? $user->getProfile() : null;
+                $user = User::getByNickname($nickname);
+                return $user->getProfile();
             } else {
                 // Fall back to trying the currently authenticated user
                 return $this->scoped;
             }
-        } else if (self::is_decimal($id)) {
-            return Profile::getKV($id);
+        } else if (self::is_decimal($id) && intval($id) > 0) {
+            return Profile::getByID($id);
         } else {
+            // FIXME: check if isAcct to identify remote profiles and not just local nicknames
             $nickname = common_canonical_nickname($id);
-            $user = User::getKV('nickname', $nickname);
-            return $user ? $user->getProfile() : null;
+            $user = User::getByNickname($nickname);
+            return $user->getProfile();
         }
     }
 
@@ -1564,4 +1565,4 @@ class ApiAction extends Action
 
         return $uri;
     }
-}
\ No newline at end of file
+}