diff options
author | zach <zach@copley.name> | 2008-07-28 19:02:21 -0400 |
---|---|---|
committer | zach <zach@copley.name> | 2008-07-28 19:02:21 -0400 |
commit | f318f41ebfa0d5400feff63fefab61928deb1d90 (patch) | |
tree | e1abac5e7a37cc2b9c68cf5449d8a3eb5c8eabd7 | |
parent | 0f4be673920be78e47642e5fe8df39fcd46a85f4 (diff) |
Twitter-compatible API: better error handling for replier_by_reply()
darcs-hash:20080728230221-ca946-68253052cfcd800a6da979e2a615d4847b1b05f3.gz
-rw-r--r-- | lib/twitterapi.php | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/twitterapi.php b/lib/twitterapi.php index b9db78dbc..1d2b0c4ba 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -63,7 +63,7 @@ class TwitterapiAction extends Action { $twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ? intval($notice->reply_to) : NULL; $twitter_status['source'] = NULL; # XXX: twitterific, twitterfox, etc. Not supported yet. $twitter_status['id'] = intval($notice->id); - $twitter_status['in_reply_to_user_id'] = ($notice->reply_to) ? $this->replier_by_reply($notice->reply_to) : NULL; + $twitter_status['in_reply_to_user_id'] = ($notice->reply_to) ? $this->replier_by_reply(intval($notice->reply_to)) : NULL; $twitter_status['favorited'] = NULL; # XXX: Not implemented on Laconica yet. if ($get_user) { @@ -206,21 +206,18 @@ class TwitterapiAction extends Action { } function replier_by_reply($reply_id) { - $notice = Notice::staticGet($reply_id); - - if (!$notice) { - common_debug("TwitterapiAction::replier_by_reply: Got a bad notice_id: $reply_id"); - } - - $profile = $notice->getProfile(); - - if (!$profile) { - common_debug("TwitterapiAction::replier_by_reply: Got a bad profile_id: $profile_id"); - return false; + if ($notice) { + $profile = $notice->getProfile(); + if ($profile) { + return intval($profile->id); + } else { + common_debug('Can\'t find a profile for notice: ' . $notice->id, __FILE__); + } + } else { + common_debug("Can't get notice: $reply_id", __FILE__); } - - return intval($profile->id); + return NULL; } // XXX: Candidate for a general utility method somewhere? |