summaryrefslogtreecommitdiff
path: root/actions/twitapidirect_messages.php
diff options
context:
space:
mode:
authorZach Copley <zach@controlyourself.ca>2008-12-09 00:53:45 -0500
committerZach Copley <zach@controlyourself.ca>2008-12-09 00:53:45 -0500
commit92ea88fd6030b3def92e100291102187be032490 (patch)
tree75aa8f8579c702191c4929bd1ebdf16faba33a87 /actions/twitapidirect_messages.php
parent84457969088363e5c3ddd0c88e82a7638392f3c2 (diff)
trac540 - Add 'since' param to Twitter-compatible API calls
darcs-hash:20081209055345-7b5ce-e48fd4c87963b8ae15859fd03d2f1f86a16f3a2b.gz
Diffstat (limited to 'actions/twitapidirect_messages.php')
-rw-r--r--actions/twitapidirect_messages.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php
index a14a9e567..535795ca4 100644
--- a/actions/twitapidirect_messages.php
+++ b/actions/twitapidirect_messages.php
@@ -40,6 +40,8 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
$count = $this->arg('count');
$since = $this->arg('since');
$since_id = $this->arg('since_id');
+ $before_id = $this->arg('before_id');
+
$page = $this->arg('page');
if (!$page) {
@@ -69,6 +71,21 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
$link = $server . $user->nickname . '/outbox';
}
+ if ($before_id) {
+ $message->whereAdd("id < $before_id");
+ }
+
+ if ($since_id) {
+ $message->whereAdd("id > $since_id");
+ }
+
+ $since = strtotime($this->arg('since'));
+
+ if ($since) {
+ $d = date('Y-m-d H:i:s', $since);
+ $message->whereAdd("created > '$d'");
+ }
+
$message->orderBy('created DESC, id DESC');
$message->limit((($page-1)*20), $count);
$message->find();
@@ -102,7 +119,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
}
$user = $apidata['user'];
- $source = $this->trimmed('source'); // Not supported by Twitter.
+ $source = $this->trimmed('source'); // Not supported by Twitter.
$reserved_sources = array('web', 'omb', 'mail', 'xmpp', 'api');
if (!$source || in_array($source, $reserved_sources)) {
@@ -113,7 +130,6 @@ class Twitapidirect_messagesAction extends TwitterapiAction {
if (!$content) {
$this->client_error(_('No message text!'), $code = 406, $apidata['content-type']);
-// } else if (mb_strlen($status) > 140) {
} else {
$content_shortened = common_shorten_links($content);
if (mb_strlen($content_shortened) > 140) {