寻找一种将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

关于javascript - 如何将批处理请求发送到Klout API,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34503794/

10-09 22:51