从fb导出评论:评论

时间:2011-09-12 15:03:58

标签: comments facebook-fql

我有点绝望。我有一个带有评论框的网站,其中有大约183000条评论我要备份。但每次我做一个fql.query,我只得到100个项目。我试过了:

SELECT xid, object_id, post_id, time, text, id FROM comment WHERE   xid='bdatapoyo' ORDER BY time DESC

之后,使用最后的“时间”

SELECT xid, object_id, post_id, time, text, id FROM comment WHERE   xid='bdatapoyo' AND time >= xxxxxxx ORDER BY time DESC

但后者只给我一个评论..

我用这段代码制作了一个PHP页面,但同样,它只抓取了100个项目:

<?php        
    require 'php-sdk/src/facebook.php';

    $facebook = new Facebook(array(
    'appId'  => 'XXXXXXXXXX',
    'secret' => 'XXXXXXXXXX',
    'cookie' => true,
    ));

    $conexion = mysql_connect("localhost", "XXXX", "XXXX");
    mysql_select_db("TVN", $conexion);

    $time_old = "1315070888";
    do {

        $fql = "SELECT fromid,time,text FROM comment WHERE xid='bdatapoyo' AND time >= " . $time_old . " ORDER BY time";

        $response = $facebook->api(array(
            'method' => 'fql.query',
            'query' =>$fql,
        ));

        foreach($response as $key => $value) {
            $sql = "INSERT INTO comment (text, uuid, time) VALUES ('" . $value["text"] . "', '" . $value["fromid"] . "', '" . $value["time"] . "')";     
            $result = mysql_query($sql);
        }

        $time_old = $response[count($response)-1]["time"];
        print_r($time_old);
    } while (count($response) > 0);

    ?>

2 个答案:

答案 0 :(得分:2)

好的,我能用LIMIT和OFFSET把它拉出来。正确的FQL是

SELECT fromid,time,text FROM comment WHERE xid='bdatapoyo' LIMIT 100 OFFSET 0

然后使用OFFSET进行分页

答案 1 :(得分:0)

此代码设置是将每个评论从您网站上的所有用户导入数据库吗?什么是xid = bdatapoyo?