diff options
author | zach <zach@copley.name> | 2008-07-16 15:18:47 -0400 |
---|---|---|
committer | zach <zach@copley.name> | 2008-07-16 15:18:47 -0400 |
commit | c998c7c60180cecbb55435629307de6f00bd637b (patch) | |
tree | 65ac3cf5c91ab88d9b8b0c3b1adace73d2d57d15 /lib | |
parent | 7b2367164ea8065754db9c92ec10dfb9ac685527 (diff) |
Twitter-compatible API: public_timeline.rss really works now
darcs-hash:20080716191847-ca946-9a75dd3aa07974408b269b31d1de3e49c5ae2a72.gz
Diffstat (limited to 'lib')
-rw-r--r-- | lib/twitterapi.php | 69 |
1 files changed, 44 insertions, 25 deletions
diff --git a/lib/twitterapi.php b/lib/twitterapi.php index 012057861..b11c04876 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -64,6 +64,29 @@ class TwitterapiAction extends Action { return $twitter_status; } + + function twitter_rss_entry_array($notice) { + + $profile = $notice->getProfile(); + + $server = common_config('site', 'server'); + + $entry = array(); + + $entry['content'] = $profile->nickname . ': ' . $notice->content; + $entry['title'] = $entry['content']; + $entry['link'] = common_local_url('shownotice', array('notice' => $notice->id));; + $entry['published'] = $this->date_iso8601($notice->created); + $entry['id'] = "tag:http://$server,$entry[published]:$entry[link]"; + $entry['updated'] = $entry['published']; + + # RSS Item specific + $entry['description'] = $entry['content']; + $entry['pubDate'] = $this->date_rfc2822($notice->created); + $entry['guid'] = $entry['link']; + + return $entry; + } function render_twitter_xml_status($twitter_status) { common_element_start('status'); @@ -94,18 +117,37 @@ class TwitterapiAction extends Action { common_element('followers_count', NULL, $twitter_user['followers_count']); common_element_end('user'); } - + + function show_twitter_rss_item($entry) { + common_element_start('item'); + common_element('title', NULL, $entry['title']); + common_element('description', NULL, $entry['description']); + common_element('pubDate', NULL, $entry['pubDate']); + common_element('guid', NULL, $entry['guid']); + common_element('link', NULL, $entry['link']); + common_element_end('item'); + } function render_twitter_json_statuses($twitter_statuses) { print(json_encode($twitter_statuses)); } - // Anyone know what date format this is? It's not RFC 2822 + // Anyone know what date format this is? // Twitter's dates look like this: "Mon Jul 14 23:52:38 +0000 2008" -- Zach function date_twitter($dt) { $t = strtotime($dt); return date("D M d G:i:s O Y", $t); } + + function date_rfc2822($dt) { + $t = strtotime($dt); + return date("r", $t); + } + + function date_iso8601($dt) { + $t = strtotime($dt); + return date("c", $t); + } function replier_by_reply($reply_id) { @@ -171,27 +213,4 @@ class TwitterapiAction extends Action { } -/* - - <item> - <title>CapitalD: @baxterd Have you read The Conquest of Cool? It looks interesting to me...</title> - <description>CapitalD: @baxterd Have you read The Conquest of Cool? It looks interesting to me...</description> - <pubDate>Mon, 14 Jul 2008 23:54:13 +0000</pubDate> - <guid>http://twitter.com/CapitalD/statuses/858499551</guid> - <link>http://twitter.com/CapitalD/statuses/858499551</link> - </item> - -*/ - - function show_twitter_rss_item($twitter_status) { - common_element_start('item'); - common_element('title', NULL, "{$twitter_status[user][screen_name]}: $twitter_status[text]"); - common_element('description', NULL, "{$twitter_status[user][screen_name]}: $twitter_status[text]"); - common_element('pubDate', NULL, "$twitter_status[created_at]"); - common_element('guid', NULL, "$twitter_status[id]"); - common_element('link', NULL, "$twitter_status[id]"); - common_element_end('item'); - } - - }
\ No newline at end of file |