Ejemplo n.º 1
0
        // Object ID for replies to replies
        if (!$objectId) {
            $objectId = isset($replyObjectIds[$tweet->in_reply_to_status_id]) ? $replyObjectIds[$tweet->in_reply_to_status_id] : 0;
        }
        $q = $db->buildQuery("SELECT id FROM connections WHERE external_id=%d", $twUser->externalId());
        $tweetConnectionId = $db->getSingleValue($q);
        // Find comment
        $q = $db->buildQuery("SELECT id FROM comments WHERE user_connection_id=%d AND external_id='%s'", $tweetConnectionId, $tweet->id);
        $commentId = $db->getSingleValue($q);
        if ($commentId) {
            continue;
        }
        // Store comment
        $comment = new Comment();
        $comment->setInReplyToId($objectId);
        $comment->setUserId($localUser->id());
        $comment->setConnectionId($tweetConnectionId);
        $comment->setExternalId($tweet->id);
        $comment->setBody($tweet->text);
        $comment->setCtime($ctime);
        $comment->save();
        // TODO: also store object_id, not doing so flattens all comments and all nesting/threading information is lost
        $replyObjectIds[$tweet->id] = $objectId ? $objectId : $comment->objectId();
        printf("%s commented on %d:%s%s%s", $twUser->name(), $objectId, PHP_EOL, $tweet->text, PHP_EOL . PHP_EOL);
    } else {
        if (isset($tweet->retweeted_status) && $tweet->user->id != $connectionId) {
            // TODO: store quoted retweet
            // echo "==== retweet ====". print_r($tweet,true). "==== end retweet ====". PHP_EOL;
        }
    }
}