NodeJS Twitter API 客户端 returns 不同的 next_cursor 和 next_cursor_str 值
NodeJS Twitter API client returns different next_cursor and next_cursor_str values
我正在使用 Twitter API(在 Node 中)并试图获得关注者。由于 Twitter 在其响应中添加了光标,因此我很容易获得前 20 个关注者,但一旦我尝试更新光标,它就会将我重定向到第一页。需要帮助更新光标。
var cursor = -1;
mainEmployee( params, cursor );
function mainEmployee( params, cursor ) {
console.log(cursor);
var url = 'followers/list.json?count=5000&' + cursor;
console.log( url );
client.get(url, params, function(error, followers, response ) {
if( !error ) {
// console.log( cursor );
// for( var i = 0; i < followers.users.length; i++ ) {
// followersData( followers.users[i] );
// }
// console.log( followers );
var new_cursor = followers.next_cursor_str;
if( cursor != 0)
mainEmployee(params, new_cursor);
else
console.log("cursor is empty");
}
else {
console.log( error );
}
});
}
我的 next_cursor
和 next_cursor_str
值也不同。
请告诉我哪里出了问题。
错误是未定义的 cursor
参数造成的。 Twitter API documentation for cursors 定义带有游标的路由,如下所示:
url_with_cursor = api_path + "&cursor=" + cursor
路线末尾必须有&cursor=
。
您应该重构 url
以定义游标:
var url = 'followers/list.json?count=5000&cursor=' + cursor;
我正在使用 Twitter API(在 Node 中)并试图获得关注者。由于 Twitter 在其响应中添加了光标,因此我很容易获得前 20 个关注者,但一旦我尝试更新光标,它就会将我重定向到第一页。需要帮助更新光标。
var cursor = -1;
mainEmployee( params, cursor );
function mainEmployee( params, cursor ) {
console.log(cursor);
var url = 'followers/list.json?count=5000&' + cursor;
console.log( url );
client.get(url, params, function(error, followers, response ) {
if( !error ) {
// console.log( cursor );
// for( var i = 0; i < followers.users.length; i++ ) {
// followersData( followers.users[i] );
// }
// console.log( followers );
var new_cursor = followers.next_cursor_str;
if( cursor != 0)
mainEmployee(params, new_cursor);
else
console.log("cursor is empty");
}
else {
console.log( error );
}
});
}
我的 next_cursor
和 next_cursor_str
值也不同。
请告诉我哪里出了问题。
错误是未定义的 cursor
参数造成的。 Twitter API documentation for cursors 定义带有游标的路由,如下所示:
url_with_cursor = api_path + "&cursor=" + cursor
路线末尾必须有&cursor=
。
您应该重构 url
以定义游标:
var url = 'followers/list.json?count=5000&cursor=' + cursor;