i need to retrieve X-Rate-Limit-Remaining
attribute from the header , i'm using the twitt Api for nodejs . how can i access this attribute . i need it to be able to sleep my loop to get all followers.
我需要从标题中检索X-Rate-Limit-Remaining属性,我正在使用nodejs的twitt Api。我该如何访问这个属性。我需要它能够睡觉我的循环以获得所有粉丝。
here's my coffee code :
这是我的咖啡代码:
loop
r = Meteor.wrapAsync(twitter.get, twitter)('followers/list',{user_id:user?.services?.twitter?.id,cursor:cursor,cout:200})
users.push.apply(users, r['users']);
console.log r
cursor=r['next_cursor']
console.log cursor
counter++
if cursor is 0
break
2 个解决方案
#1
2
twId = user?.services?.twitter?.id
getFollowers = Meteor.wrapAsync (cb) ->
twitter.get 'followers/list', {user_id:twId,cursor:cursor,cout:200}, (err, data, response) ->
cb(err, response)
r = getFollowers()
#2
1
The callback you pass to Twitter.followers()
should look something like function(error, data, response)
. The response
value that is returned is an object of type http.IncomingMessage, which has various properties which will allow you to access the X-Rate-Limit-Remaining
value (including .headers
and .rawHeaders
)
您传递给Twitter.followers()的回调应该类似于函数(错误,数据,响应)。返回的响应值是http.IncomingMessage类型的对象,它具有各种属性,允许您访问X-Rate-Limit-Remaining值(包括.headers和.rawHeaders)
#1
2
twId = user?.services?.twitter?.id
getFollowers = Meteor.wrapAsync (cb) ->
twitter.get 'followers/list', {user_id:twId,cursor:cursor,cout:200}, (err, data, response) ->
cb(err, response)
r = getFollowers()
#2
1
The callback you pass to Twitter.followers()
should look something like function(error, data, response)
. The response
value that is returned is an object of type http.IncomingMessage, which has various properties which will allow you to access the X-Rate-Limit-Remaining
value (including .headers
and .rawHeaders
)
您传递给Twitter.followers()的回调应该类似于函数(错误,数据,响应)。返回的响应值是http.IncomingMessage类型的对象,它具有各种属性,允许您访问X-Rate-Limit-Remaining值(包括.headers和.rawHeaders)