简体   繁体   中英

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. All I can find in the Klout docs is a way to send a single user. eg:

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. I am using 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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