X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fapiaction.php;h=a562f5d976914f7d7656369dc340b2800df0d919;hb=1111187d845ecd34eba1c03473f6adbc08f6ca15;hp=354e1887bb8d06c0532cd2e2e04ecbe7adb41c90;hpb=29d0871e5a5b2561387bcad40ef4644ee1c2be08;p=quix0rs-gnu-social.git diff --git a/lib/apiaction.php b/lib/apiaction.php old mode 100644 new mode 100755 index 354e1887bb..a562f5d976 --- a/lib/apiaction.php +++ b/lib/apiaction.php @@ -54,7 +54,7 @@ @subsection usermethods_sec User Methods - @subsection directmessagemethods_sec Direct Message Methods + @subsection directmessagemethods_sec Direct Message Methods (now a plugin) @subsection friendshipmethods_sec Friendship Methods @@ -127,6 +127,7 @@ class ApiAction extends Action var $since_id = null; var $source = null; var $callback = null; + var $format = null; var $access = self::READ_ONLY; // read (default) or read-write @@ -215,6 +216,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 +228,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); } @@ -241,8 +244,6 @@ class ApiAction extends Action $twitter_user['created_at'] = $this->dateTwitter($profile->created); - $twitter_user['favourites_count'] = $profile->faveCount(); // British spelling! - $timezone = 'UTC'; if (!empty($user) && $user->timezone) { @@ -288,6 +289,9 @@ class ApiAction extends Action $twitter_user['statusnet_profile_url'] = $profile->profileurl; + // The event call to handle NoticeSimpleStatusArray lets plugins add data to the output array + Event::handle('TwitterUserArray', array($profile, &$twitter_user, $this->scoped, array())); + return $twitter_user; } @@ -297,9 +301,9 @@ class ApiAction extends Action if (!empty($notice->repeat_of)) { $original = Notice::getKV('id', $notice->repeat_of); - if (!empty($original)) { - $original_array = $this->twitterSimpleStatusArray($original, $include_user); - $base['retweeted_status'] = $original_array; + if ($original instanceof Notice) { + $orig_array = $this->twitterSimpleStatusArray($original, $include_user); + $base['retweeted_status'] = $orig_array; } } @@ -315,7 +319,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; } @@ -324,7 +331,7 @@ class ApiAction extends Action $source = null; $ns = $notice->getSource(); - if ($ns) { + if ($ns instanceof Notice_source) { if (!empty($ns->name) && !empty($ns->url)) { $source = 'getBestName(); - $entry['author-uri'] = $from->homepage; - - $entry['avatar'] = $from->avatarUrl(AVATAR_STREAM_SIZE); - try { - $avatar = $from->getAvatar(AVATAR_STREAM_SIZE); - $entry['avatar-type'] = $avatar->mediatype; - } catch (Exception $e) { - $entry['avatar-type'] = 'image/png'; - } - - // RSS item specific - - $entry['description'] = $entry['content']; - $entry['pubDate'] = common_date_rfc2822($message->created); - $entry['guid'] = $entry['link']; - - return $entry; - } - - function showSingleXmlDirectMessage($message) - { - $this->initDocument('xml'); - $dmsg = $this->directMessageArray($message); - $this->showXmlDirectMessage($dmsg, true); - $this->endDocument('xml'); - } - - function showSingleJsonDirectMessage($message) - { - $this->initDocument('json'); - $dmsg = $this->directMessageArray($message); - $this->showJsonObjects($dmsg); - $this->endDocument('json'); - } - function showAtomGroups($group, $title, $id, $link, $subtitle=null, $selfuri=null) { $this->initDocument('atom'); @@ -1319,7 +1237,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 +1263,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 +1317,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 +1378,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;