Beispiel #1
0
         $objectId = isset($objectIds[$tweet->in_reply_to_status_id]) ? $objectIds[$tweet->in_reply_to_status_id] : 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;
     }
Beispiel #2
0
 *
 * @todo verify backwards compatibility (should be a See Other redirect?)
 */
// require_once "../lib/init.php";
use Kiki\Comment;
if ($_POST) {
    $errors = array();
    list($dummy, $objectId, $last) = explode("_", $_POST['last']);
    if (!$user->id()) {
        $errors[] = "Je bent niet ingelogd.";
    }
    if (!($body = $_POST['comment'])) {
        $errors[] = "Je kunt geen leeg berichtje opslaan!";
    }
    if (!count($errors)) {
        $comment = new Comment();
        $comment->setInReplyToId($objectId);
        $comment->setUserId($user->id());
        $comment->setBody($body);
        $comment->setIpAddr($_SERVER['REMOTE_ADDR']);
        $comment->save();
    }
    if ($_POST['json']) {
        $response = array();
        $response['formId'] = $_POST['formId'];
        $response['objectId'] = $objectId;
        $response['comments'] = Comments::show($objectId, $last);
        $response['errors'] = $errors;
        header('Content-type: application/json');
        echo json_encode($response);
        exit;
Beispiel #3
0
     if (!$fbUser->id()) {
         $fbUser->loadRemoteData($apiUser->api());
         $fbUser->link(0);
     }
     $ctime = $reply['time'];
     $objectId = isset($objectIds[$postId]) ? $objectIds[$postId] : 0;
     $q = $db->buildQuery("SELECT id FROM connections WHERE external_id=%d", $fbUser->externalId());
     $connectionId = $db->getSingleValue($q);
     // Find comment
     $q = $db->buildQuery("SELECT id FROM comments WHERE user_connection_id=%d AND external_id='%s'", $connectionId, $externalId);
     $commentId = $db->getSingleValue($q);
     if ($commentId) {
         continue;
     }
     // Store comment
     $comment = new Comment();
     // TODO: support nested comments using $reply['parent_id']
     // (Facebook UI does not support that yet, but their post-July 2013 data model does.)
     $comment->setInReplyToId($objectId);
     $comment->setUserId($localUser->id());
     $comment->setConnectionId($connectionId);
     $comment->setExternalId($externalId);
     $comment->setBody($reply['text']);
     $comment->setCtime($ctime);
     $comment->save();
     $object = ObjectCache::get($objectId);
     $label = method_exists($object, 'title') ? $object->title() : null;
     printf("%s commented on %s %d (%s):%s%s%s", $fbUser->name(), $object->type(), $objectId, $label, PHP_EOL, $reply['text'], PHP_EOL . PHP_EOL);
 }
 // Get likes
 $q = "select post_id, user_id, object_id, object_type from like where post_id in ({$qPostIds})";