]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/apiaction.php
No nickname in profile listing
[quix0rs-gnu-social.git] / lib / apiaction.php
index 354e1887bb8d06c0532cd2e2e04ecbe7adb41c90..55860efa554286d900191ff25076916f6261771d 100644 (file)
@@ -215,6 +215,8 @@ class ApiAction extends Action
 
         // TODO: avatar url template (example.com/user/avatar?size={x}x{y})
         $twitter_user['profile_image_url'] = Avatar::urlByProfile($profile, AVATAR_STREAM_SIZE);
+        $twitter_user['profile_image_url_https'] = $twitter_user['profile_image_url'];
+
         // START introduced by qvitter API, not necessary for StatusNet API
         $twitter_user['profile_image_url_profile_size'] = Avatar::urlByProfile($profile, AVATAR_PROFILE_SIZE);
         try {
@@ -225,7 +227,7 @@ class ApiAction extends Action
         }
         $twitter_user['profile_image_url_original'] = $origurl;
 
-        $twitter_user['groups_count'] = $profile->getGroups(0, null)->N;
+        $twitter_user['groups_count'] = $profile->getGroupCount();
         foreach (array('linkcolor', 'backgroundcolor') as $key) {
             $twitter_user[$key] = Profile_prefs::getConfigData($profile, 'theme', $key);
         }
@@ -315,7 +317,10 @@ class ApiAction extends Action
         $twitter_status['truncated'] = false; # Not possible on StatusNet
         $twitter_status['created_at'] = $this->dateTwitter($notice->created);
         try {
-            $in_reply_to = $notice->getParent()->id;
+            // We could just do $notice->reply_to but maybe the future holds a
+            // different story for parenting.
+            $parent = $notice->getParent();
+            $in_reply_to = $parent->id;
         } catch (Exception $e) {
             $in_reply_to = null;
         }
@@ -379,13 +384,15 @@ class ApiAction extends Action
             $twitter_status['attachments'] = array();
 
             foreach ($attachments as $attachment) {
-                $enclosure_o=$attachment->getEnclosure();
-                if ($enclosure_o) {
+                try {
+                    $enclosure_o = $attachment->getEnclosure();
                     $enclosure = array();
                     $enclosure['url'] = $enclosure_o->url;
                     $enclosure['mimetype'] = $enclosure_o->mimetype;
                     $enclosure['size'] = $enclosure_o->size;
                     $twitter_status['attachments'][] = $enclosure;
+                } catch (ServerException $e) {
+                    // There was not enough metadata available
                 }
             }
         }
@@ -505,13 +512,15 @@ class ApiAction extends Action
             $enclosures = array();
 
             foreach ($attachments as $attachment) {
-                $enclosure_o=$attachment->getEnclosure();
-                if ($enclosure_o) {
+                try {
+                    $enclosure_o = $attachment->getEnclosure();
                     $enclosure = array();
                     $enclosure['url'] = $enclosure_o->url;
                     $enclosure['mimetype'] = $enclosure_o->mimetype;
                     $enclosure['size'] = $enclosure_o->size;
                     $enclosures[] = $enclosure;
+                } catch (ServerException $e) {
+                    // There was not enough metadata available
                 }
             }
 
@@ -1319,7 +1328,6 @@ class ApiAction extends Action
         default:
             // TRANS: Client error on an API request with an unsupported data format.
             $this->clientError(_('Not a supported data format.'));
-            break;
         }
 
         return;
@@ -1346,7 +1354,6 @@ class ApiAction extends Action
         default:
             // TRANS: Client error on an API request with an unsupported data format.
             $this->clientError(_('Not a supported data format.'));
-            break;
         }
         return;
     }
@@ -1401,7 +1408,6 @@ class ApiAction extends Action
         default:
             // TRANS: Client error on an API request with an unsupported data format.
             $this->clientError(_('Not a supported data format.'));
-            return;
         }
         return;
     }
@@ -1463,7 +1469,7 @@ class ApiAction extends Action
             } else if ($this->arg('screen_name')) {
                 $nickname = common_canonical_nickname($this->arg('screen_name'));
                 $user = User::getKV('nickname', $nickname);
-                return $user ? $user->getProfile() : null;
+                return $user instanceof User ? $user->getProfile() : null;
             } else {
                 // Fall back to trying the currently authenticated user
                 return $this->scoped;