From 924491f08a24201c7bda45b4d4be16ccebba97c0 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 29 Sep 2008 01:08:26 -0400 Subject: Twitter-compatible API: Direct messages work (everything but destroy()) darcs-hash:20080929050826-7b5ce-201624b32e174ae85b906b92353e39aa043838fa.gz --- lib/twitterapi.php | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/twitterapi.php b/lib/twitterapi.php index d427a7b4e..5bcb538f9 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -121,7 +121,7 @@ class TwitterapiAction extends Action { } - function twitter_dm_array($message) { + function twitter_dmsg_array($message) { $twitter_dm = array(); @@ -214,7 +214,21 @@ class TwitterapiAction extends Action { exit(); } - function show_twitter_xml_dm($twitter_dm) { + function show_single_xml_dmsg($message) { + $this->init_document('xml'); + $dmsg = $this->twitter_dmsg_array($message); + $this->show_twitter_xml_dmsg($dmsg); + $this->end_document('xml'); + } + + function show_single_json_dmsg($message) { + $this->init_document('json'); + $dmsg = $this->twitter_dmsg_array($message); + $this->show_twitter_json_dm($dmsg); + $this->end_document('json'); + } + + function show_twitter_xml_dmsg($twitter_dm) { common_element_start('direct_message'); foreach($twitter_dm as $element => $value) { if ($element == 'sender' || $element == 'recipient') { @@ -405,4 +419,26 @@ class TwitterapiAction extends Action { } return; } + + function get_user($id) { + if (is_numeric($id)) { + return User::staticGet($id); + } else { + return User::staticGet('nickname', $id); + } + } + + function get_profile($id) { + if (is_numeric($id)) { + return Profile::staticGet($id); + } else { + $user = User::staticGet('nickname', $id); + if ($user) { + return $user->getProfile(); + } else { + return NULL; + } + } + } + } \ No newline at end of file -- cgit v1.2.3-54-g00ecf