@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
var $since_id = null;
var $source = null;
var $callback = null;
+ var $format = null;
var $access = self::READ_ONLY; // read (default) or read-write
// 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 {
}
$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);
}
$twitter_user['created_at'] = $this->dateTwitter($profile->created);
- $twitter_user['favourites_count'] = $profile->faveCount(); // British spelling!
-
$timezone = 'UTC';
if (!empty($user) && $user->timezone) {
$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;
}
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;
}
}
$source = null;
$ns = $notice->getSource();
- if ($ns) {
+ if ($ns instanceof Notice_source) {
if (!empty($ns->name) && !empty($ns->url)) {
$source = '<a href="'
. htmlspecialchars($ns->url)
}
if (!is_null($this->scoped)) {
- $twitter_status['favorited'] = $this->scoped->hasFave($notice);
$twitter_status['repeated'] = $this->scoped->hasRepeated($notice);
} else {
- $twitter_status['favorited'] = false;
$twitter_status['repeated'] = false;
}
$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
}
}
}
$twitter_status['statusnet_html'] = $notice->rendered;
$twitter_status['statusnet_conversation_id'] = intval($notice->conversation);
+ // The event call to handle NoticeSimpleStatusArray lets plugins add data to the output array
+ Event::handle('NoticeSimpleStatusArray', array($notice, &$twitter_status, $this->scoped,
+ array('include_user'=>$include_user)));
+
return $twitter_status;
}
$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
}
}
{
$details = array();
+ $source_profile = $source->getProfile();
+ $target_profile = $target->getProfile();
+
$details['screen_name'] = $source->nickname;
- $details['followed_by'] = $target->isSubscribed($source);
- $details['following'] = $source->isSubscribed($target);
+ $details['followed_by'] = $target->isSubscribed($source_profile);
+ $details['following'] = $source->isSubscribed($target_profile);
$notifications = false;
- if ($source->isSubscribed($target)) {
+ if ($source->isSubscribed($target_profile)) {
$sub = Subscription::pkeyGet(array('subscriber' =>
$source->id, 'subscribed' => $target->id));
}
$details['notifications_enabled'] = $notifications;
- $details['blocking'] = $source->hasBlocked($target);
+ $details['blocking'] = $source->hasBlocked($target_profile);
$details['id'] = intval($source->id);
return $details;
$this->elementEnd('entry');
}
- function showXmlDirectMessage($dm, $namespaces=false)
- {
- $attrs = array();
- if ($namespaces) {
- $attrs['xmlns:statusnet'] = 'http://status.net/schema/api/1/';
- }
- $this->elementStart('direct_message', $attrs);
- foreach($dm as $element => $value) {
- switch ($element) {
- case 'sender':
- case 'recipient':
- $this->showTwitterXmlUser($value, $element);
- break;
- case 'text':
- $this->element($element, null, common_xml_safe_str($value));
- break;
- default:
- $this->element($element, null, $value);
- break;
- }
- }
- $this->elementEnd('direct_message');
- }
-
- function directMessageArray($message)
- {
- $dmsg = array();
-
- $from_profile = $message->getFrom();
- $to_profile = $message->getTo();
-
- $dmsg['id'] = intval($message->id);
- $dmsg['sender_id'] = intval($from_profile->id);
- $dmsg['text'] = trim($message->content);
- $dmsg['recipient_id'] = intval($to_profile->id);
- $dmsg['created_at'] = $this->dateTwitter($message->created);
- $dmsg['sender_screen_name'] = $from_profile->nickname;
- $dmsg['recipient_screen_name'] = $to_profile->nickname;
- $dmsg['sender'] = $this->twitterUserArray($from_profile, false);
- $dmsg['recipient'] = $this->twitterUserArray($to_profile, false);
-
- return $dmsg;
- }
-
- function rssDirectMessageArray($message)
- {
- $entry = array();
-
- $from = $message->getFrom();
-
- $entry['title'] = sprintf('Message from %1$s to %2$s',
- $from->nickname, $message->getTo()->nickname);
-
- $entry['content'] = common_xml_safe_str($message->rendered);
- $entry['link'] = common_local_url('showmessage', array('message' => $message->id));
- $entry['published'] = common_date_iso8601($message->created);
-
- $taguribase = TagURI::base();
-
- $entry['id'] = "tag:$taguribase:$entry[link]";
- $entry['updated'] = $entry['published'];
-
- $entry['author-name'] = $from->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');
default:
// TRANS: Client error on an API request with an unsupported data format.
$this->clientError(_('Not a supported data format.'));
- break;
}
return;
default:
// TRANS: Client error on an API request with an unsupported data format.
$this->clientError(_('Not a supported data format.'));
- break;
}
return;
}
default:
// TRANS: Client error on an API request with an unsupported data format.
$this->clientError(_('Not a supported data format.'));
- return;
}
return;
}
} 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;