コード例 #1
0
            $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})";
        $rs = $apiUser->api()->api('fql', 'get', array('q' => $q));
        if (!$rs || !isset($rs['data'])) {
            continue;
        }
        foreach ($rs['data'] as $like) {
            list($uid, $postId) = explode("_", $like['post_id']);
            $objectId = isset($objectIds[$postId]) ? $objectIds[$postId] : 0;
            $fbUser = User\Factory::getInstance('User_Facebook', $like['user_id']);
            $localUser = ObjectCache::getByType('User', $fbUser->kikiUserId());
            if (!$fbUser->id()) {
                $fbUser->loadRemoteData($apiUser->api());
                $fbUser->link(0);
            }
            $q = "INSERT INTO likes (object_id, user_connection_id,ctime) VALUES({$objectId}, " . $fbUser->id() . ",now()) on duplicate key UPDATE user_connection_id=" . $fbUser->id();
            $rsLike = $db->query($q);
            if ($db->affectedRows($rs) == 1) {
                $object = ObjectCache::get($objectId);
                $label = method_exists($object, 'title') ? $object->title() : null;
                printf("%s likes %s %d (%s)" . PHP_EOL, $fbUser->name(), $object->type(), $objectId, $label);
            }
        }
    }
}