我想获取Feed中每个帖子的帖子洞察信息。我无法从函数中传递参数。这是代码:
function load_post(page_id, tok)
{
var data = {
access_token : tok,
};
FB.api("/" + page_id + "/feed?fields=id,name",'get',data ,function (response) {
if (response && !response.error) {
console.log(response);
for (var i = 0; i < response.data.length; i++) {
var r = "";
(function(post_id, data, r) {
FB.api("/" + post_id + "/insights/post_impressions",'get',data ,function (response_insight) {
r = response_insight.data[0].values[0].value;
});
})(response.data[i].id, data, r);
alert(r);
}
}
});
}
我不知道错误在哪里。我是jquery / javascript的新手,我觉得这是一个功能问题。你能帮助我吗?非常感谢。
PS:我的目标是采取response_insight.data [0] .values [0] .value value
这是response_insight响应:
data: Array[1]
0: Object
description: "Lifetime: The number of impressions of your Page post. (Total Count)"
id: "my_id_post/insights/post_impressions/lifetime"
name: "post_impressions"
period: "lifetime"
title: "Lifetime Post Total Impressions"
values: Array[1]
0: Object
value: 676