繁体   English   中英

如何将批处理请求发送到Klout API

[英]How to send batch request to Klout API

寻找一种将KloutId数组发送到其API并获取其Klout主题的方法。 我在Klout文档中可以找到的只是一种发送单个用户的方式。 例如:

http://api.klout.com/v2/user.json/635263/topics?key=API_KEY_HERE

基本上要达到其速率限制,因此希望以10组为一组,总共可以抓取100个用户。 我正在使用Node.js

当前代码:

    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
});

似乎不再支持批量请求:

“为了确保最高的数据可用性和最低的延迟,您将不再能够进行批量用户呼叫。将增加速率限制以进行补偿。”

http://developer.klout.com/blog/read/api_v2_launch

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM