diff options
author | Zach Copley <zach@controlyourself.ca> | 2008-09-29 01:08:26 -0400 |
---|---|---|
committer | Zach Copley <zach@controlyourself.ca> | 2008-09-29 01:08:26 -0400 |
commit | 924491f08a24201c7bda45b4d4be16ccebba97c0 (patch) | |
tree | eefba7055dd15b443d59834da9cdacef653570f1 /lib/twitterapi.php | |
parent | 10f4ee7abb889aeb21b45efb563ebe5c2f4d9c94 (diff) |
Twitter-compatible API: Direct messages work (everything but destroy())
darcs-hash:20080929050826-7b5ce-201624b32e174ae85b906b92353e39aa043838fa.gz
Diffstat (limited to 'lib/twitterapi.php')
-rw-r--r-- | lib/twitterapi.php | 40 |
1 files changed, 38 insertions, 2 deletions
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 |