给定Instagram评论id,如何检索其原始媒体id?将计数传递到http.call?
问题1: 我只有Instagram评论id,是否可以检索其原始媒体id 问题2: 使用instagram媒体id,通过http.call(GET)收集特定媒体id的评论 假设totalMediaCount为33给定Instagram评论id,如何检索其原始媒体id?将计数传递到http.call?,http,instagram-api,Http,Instagram Api,问题1: 我只有Instagram评论id,是否可以检索其原始媒体id 问题2: 使用instagram媒体id,通过http.call(GET)收集特定媒体id的评论 假设totalMediaCount为33 for(i=0; i<totalMediaCount; i++) { HTTP.call('GET', 'https://api.instagram.com/v1/media/' + media-id[i] + '/comments?access_token=' + ins
for(i=0; i<totalMediaCount; i++) {
HTTP.call('GET', 'https://api.instagram.com/v1/media/' + media-id[i] + '/comments?access_token=' + instagramAccessToken, {}, function(error, response) {
if (error) {
console.log(error);
} else {
//console.log(response);
console.log(i);
});
}
我希望得到这样的结果:
0
1
2
3
4
5
...
30
31
32
问题是什么
注释\u id
获取媒体\u id
,它没有APIHTTP.call
是异步的,因此for
is循环在执行第一个HTTP.call时完成for(i=0; i<totalMediaCount; i++) {
var index = i;
HTTP.call('GET', 'https://api.instagram.com/v1/media/' + media-id[index] + '/comments?access_token=' + instagramAccessToken, {}, function(error, response) {
if (error) {
console.log(error);
} else {
//console.log(response);
console.log(index);
});
}
for(i=0;我感谢你的答案。在#1上注明,但对#2来说仍然没有运气。它仍然显示33,33,…,33而不是0,1,2,…,32,33。我认为有效的解决方案是
for(i=0; i<totalMediaCount; i++) {
var index = i;
HTTP.call('GET', 'https://api.instagram.com/v1/media/' + media-id[index] + '/comments?access_token=' + instagramAccessToken, {}, function(error, response) {
if (error) {
console.log(error);
} else {
//console.log(response);
console.log(index);
});
}