使用JavaScript从Facebook帖子中检索评论

时间:2013-07-17 16:15:33

标签: javascript facebook-javascript-sdk facebook-comments

我正在尝试使用JavaScript从Facebook帖子中检索评论。我不知道如何访问评论,我尝试了get_comments.responseText但是返回了“undefined”。它是response.text或有评论的数据,我不知道如何获得评论。这是我的代码:

var get_comments =
($.get('https://graph.facebook.com/'+POST_ID+'/comments'));
console.log(get_comments);

以上记录以下内容

Object {
    readyState: 1,
    getResponseHeader: function,
    getAllResponseHeaders: function,
    setRequestHeader: function,
    overrideMimeType: function…
}
abort: function (e) {
    var t = e || T;
    return l && l.abort(t), k(0, t), this
}
always: function () {
    return i.done(arguments).fail(arguments), this
}
complete: function () {
    if (u) {
        var t = u.length;
        (function i(t) {
            b.each(t, function (t, n) {
                var r = b.type(n);
                "function" === r ? e.unique && p.has(n) || u.push(n) : n && n.length && "string" !== r && i(n)
            })
        })(arguments), n ? o = u.length : r && (s = t, c(r))
    }
    return this
}
done: function () {
    if (u) {
        var t = u.length;
        (function i(t) {
            b.each(t, function (t, n) {
                var r = b.type(n);
                "function" === r ? e.unique && p.has(n) || u.push(n) : n && n.length && "string" !== r && i(n)
            })
        })(arguments), n ? o = u.length : r && (s = t, c(r))
    }
    return this
}
error: function () {
    if (u) {
        var t = u.length;
        (function i(t) {
            b.each(t, function (t, n) {
                var r = b.type(n);
                "function" === r ? e.unique && p.has(n) || u.push(n) : n && n.length && "string" !== r && i(n)
            })
        })(arguments), n ? o = u.length : r && (s = t, c(r))
    }
    return this
}
fail: function () {
    if (u) {
        var t = u.length;
        (function i(t) {
            b.each(t, function (t, n) {
                var r = b.type(n);
                "function" === r ? e.unique && p.has(n) || u.push(n) : n && n.length && "string" !== r && i(n)
            })
        })(arguments), n ? o = u.length : r && (s = t, c(r))
    }
    return this
}
getAllResponseHeaders: function () {
    return 2 === x ? a : null
}
getResponseHeader: function (e) {
    var t;
    if (2 === x) {
        if (!c) {
            c = {};
            while (t = Tn.exec(a)) c[t[1].toLowerCase()] = t[2]
        }
        t = c[e.toLowerCase()]
    }
    return null == t ? null : t
}
overrideMimeType: function (e) {
    return x || (p.mimeType = e), this
}
pipe: function () {
    var e = arguments;
    return b.Deferred(function (n) {
        b.each(t, function (t, o) {
            var a = o[0],
                s = b.isFunction(e[t]) && e[t];
            i[o[1]](function () {
                var e = s && s.apply(this, arguments);
                e && b.isFunction(e.promise) ? e.promise().done(n.resolve).fail(n.reject).progress(n.notify) : n[a + "With"](this === r ? n.promise() : this, s ? [e] : arguments)
            })
        }), e = null
    }).promise()
}
progress: function () {
    if (u) {
        var t = u.length;
        (function i(t) {
            b.each(t, function (t, n) {
                var r = b.type(n);
                "function" === r ? e.unique && p.has(n) || u.push(n) : n && n.length && "string" !== r && i(n)
            })
        })(arguments), n ? o = u.length : r && (s = t, c(r))
    }
    return this
}
promise: function (e) {
    return null != e ? b.extend(e, r) : r
}
readyState: 4
responseText: "{↵   "
data ": [↵      ↵   ]↵}"
setRequestHeader: function (e, t) {
    var n = e.toLowerCase();
    return x || (e = v[n] = v[n] || e, y[e] = t), this
}
state: function () {
    return n
}
status: 200
statusCode: function (e) {
    var t;
    if (e)
        if (2 > x)
            for (t in e) m[t] = [m[t], e[t]];
        else N.always(e[N.status]);
    return this
}
statusText: "OK"
success: function () {
    if (u) {
        var t = u.length;
        (function i(t) {
            b.each(t, function (t, n) {
                var r = b.type(n);
                "function" === r ? e.unique && p.has(n) || u.push(n) : n && n.length && "string" !== r && i(n)
            })
        })(arguments), n ? o = u.length : r && (s = t, c(r))
    }
    return this
}
then: function () {
    var e = arguments;
    return b.Deferred(function (n) {
        b.each(t, function (t, o) {
            var a = o[0],
                s = b.isFunction(e[t]) && e[t];
            i[o[1]](function () {
                var e = s && s.apply(this, arguments);
                e && b.isFunction(e.promise) ? e.promise().done(n.resolve).fail(n.reject).progress(n.notify) : n[a + "With"](this === r ? n.promise() : this, s ? [e] : arguments)
            })
        }), e = null
    }).promise()
}

1 个答案:

答案 0 :(得分:1)

首先阅读如何正确地从Facebook获取评论:

https://developers.facebook.com/docs/reference/opengraph/action-type/og.posts

如果你还需要任何帮助,那就说...祝你好运!