diff options
author | Zach Copley <zach@controlyourself.ca> | 2009-03-10 16:15:57 -0700 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2009-03-10 16:15:57 -0700 |
commit | 91980c73a76bcbedd5f23a3232988a32aa8c7127 (patch) | |
tree | 94a49d0111d3484db7321032f879ac580b1d5065 /actions/twitapidirect_messages.php | |
parent | 945bbf00dc9ee106359e9387956c72c1290d12fc (diff) |
Updates to the API to improve Atom feeds
Diffstat (limited to 'actions/twitapidirect_messages.php')
-rw-r--r-- | actions/twitapidirect_messages.php | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php index ce98bf6ec..7101db8df 100644 --- a/actions/twitapidirect_messages.php +++ b/actions/twitapidirect_messages.php @@ -38,7 +38,6 @@ class Twitapidirect_messagesAction extends TwitterapiAction function show_messages($args, $apidata, $type) { - $user = $apidata['user']; $count = $this->arg('count'); @@ -102,7 +101,17 @@ class Twitapidirect_messagesAction extends TwitterapiAction $this->show_rss_dmsgs($message, $title, $link, $subtitle); break; case 'atom': - $this->show_atom_dmsgs($message, $title, $link, $subtitle); + $selfuri = common_root_url() . 'api/direct_messages'; + $selfuri .= ($type == 'received') ? '.atom' : '/sent.atom'; + $taguribase = common_config('integration', 'taguri'); + + if ($type == 'sent') { + $id = "tag:$taguribase:SentDirectMessages:" . $user->id; + } else { + $id = "tag:$taguribase:DirectMessages:" . $user->id; + } + + $this->show_atom_dmsgs($message, $title, $link, $subtitle, $selfuri, $id); break; case 'json': $this->show_json_dmsgs($message); @@ -261,16 +270,17 @@ class Twitapidirect_messagesAction extends TwitterapiAction } - function show_atom_dmsgs($message, $title, $link, $subtitle) + function show_atom_dmsgs($message, $title, $link, $subtitle, $selfuri, $id) { $this->init_document('atom'); $this->element('title', null, $title); - $siteserver = common_config('site', 'server'); - $this->element('id', null, "tag:$siteserver,2008:DirectMessage"); + $this->element('id', null, $id); $this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null); - $this->element('updated', null, common_date_iso8601(strftime('%c'))); + $this->element('link', array('href' => $selfuri, 'rel' => 'self', + 'type' => 'application/atom+xml'), null); + $this->element('updated', null, common_date_iso8601('now')); $this->element('subtitle', null, $subtitle); if (is_array($message)) { |