[英]How to send batch request to Klout API
Looking for a way to send an array of KloutId to their API and get back their Klout Topics. 寻找一种将KloutId数组发送到其API并获取其Klout主题的方法。 All I can find in the Klout docs is a way to send a single user.
我在Klout文档中可以找到的只是一种发送单个用户的方式。 eg:
例如:
http://api.klout.com/v2/user.json/635263/topics?key=API_KEY_HERE http://api.klout.com/v2/user.json/635263/topics?key=API_KEY_HERE
Basically running up against their rate limits, would like to batch in groups of 10 to be able to grab 100 users total. 基本上要达到其速率限制,因此希望以10组为一组,总共可以抓取100个用户。 I am using Node.js
我正在使用Node.js
Current Code: 当前代码:
async.series([
function(callback){
// call to twitter api to get friends
T.get('friends/ids', { screen_name: screenname }, function (err, data, response) {
if(err) console.error(err)
friends = data;
callback(null);
})
},
function(callback){
friends.forEach(function(friend){
var friend = JSON.stringify(friend)
request(`http://api.klout.com/v2/identity.json/tw/${friend}?key=${process.env.KLOUT}`, function(err, res, body){
kloutId = JSON.parse(body).id;
// get topics
request(`http://api.klout.com/v2/user.json/${kloutId}/topics?key=${process.env.KLOUT}`, function(err, res, body){
var topics = JSON.parse(body)
for(var topic in topics){
console.log("Topic: ", topics[topic].displayName)
}
})
})
})
callback(null);
}
],
function(err, results){
// Pick off top 10 topics of all users here
});
Appears the bulk requests are no longer supported: 似乎不再支持批量请求:
"To ensure the highest data availability and the lowest latency, you will no longer be able to make bulk user calls. Rate limits will be increased to compensate." “为了确保最高的数据可用性和最低的延迟,您将不再能够进行批量用户呼叫。将增加速率限制以进行补偿。”
http://developer.klout.com/blog/read/api_v2_launch http://developer.klout.com/blog/read/api_v2_launch
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.