$client = new TwitterOAuthClient($token->key, $token->secret);
common_debug($this->name() . ' - Grabbing friends timeline with OAuth.');
} else {
- $client = new TwitterBasicAuthClient($flink);
- common_debug($this->name() . ' - Grabbing friends timeline with basic auth.');
+ common_debug("Skipping friends timeline for $flink->foreign_id since not OAuth.");
}
$timeline = null;
try {
- $timeline = $client->statusesFriendsTimeline();
+ $timeline = $client->statusesHomeTimeline();
} catch (Exception $e) {
common_log(LOG_WARNING, $this->name() .
' - Twitter client unable to get friends timeline for user ' .
continue;
}
- $this->saveStatus($status, $flink);
+ $notice = $this->saveStatus($status);
+
+ if (!empty($notice)) {
+ Inbox::insertNotice($flink->user_id, $notice->id);
+ }
}
// Okay, record the time we synced with Twitter for posterity
$flink->update();
}
- function saveStatus($status, $flink=null)
+ function saveStatus($status)
{
$profile = $this->ensureProfile($status->user);
return $dupe;
}
+ common_debug("Saving status {$status->id} with data " . print_r($status, true));
+
// If it's a retweet, save it as a repeat!
if (!empty($status->retweeted_status)) {
+ common_log(LOG_INFO, "Status {$status->id} is a retweet of {$status->retweeted_status->id}.");
$original = $this->saveStatus($status->retweeted_status);
- return $original->repeat($profile->id, 'twitter');
+ $repeat = $original->repeat($profile->id, 'twitter');
+ common_log(LOG_INFO, "Saved {$repeat->id} as a repeat of {$original->id}");
+ return $repeat;
}
$notice = new Notice();
$notice->reply_to = null;
if (!empty($status->in_reply_to_status_id)) {
+ common_log(LOG_INFO, "Status {$status->id} is a reply to status {$status->in_reply_to_status_id}");
$replyUri = $this->makeStatusURI($status->in_reply_to_screen_name, $status->in_reply_to_status_id);
$reply = Notice::staticGet('uri', $replyUri);
- if (!empty($reply)) {
+ if (empty($reply)) {
+ common_log(LOG_INFO, "Couldn't find local notice for status {$status->in_reply_to_status_id}");
+ } else {
+ common_log(LOG_INFO, "Found local notice {$reply->id} for status {$status->in_reply_to_status_id}");
$notice->reply_to = $reply->id;
$notice->conversation = $reply->conversation;
}
if (empty($notice->conversation)) {
$conv = Conversation::create();
$notice->conversation = $conv->id;
+ common_log(LOG_INFO, "No known conversation for status {$status->id} so making a new one {$conv->id}.");
}
$notice->is_local = Notice::GATEWAY;
Event::handle('EndNoticeSave', array($notice));
}
- if (!empty($flink)) {
- Inbox::insertNotice($flink->user_id, $notice->id);
- }
$notice->blowOnInsert();
return $notice;