From 91980c73a76bcbedd5f23a3232988a32aa8c7127 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 10 Mar 2009 16:15:57 -0700 Subject: Updates to the API to improve Atom feeds --- actions/twitapidirect_messages.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'actions/twitapidirect_messages.php') 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)) { -- cgit v1.2.3-54-g00ecf