簡體   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