推特关注者列表 [英] twitter followers list

查看:304
本文介绍了推特关注者列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我需要为我的研究下载Twitter用户列表的关注者列表.我正在使用C#代码,并且已经访问了 https://dev.twitter.com/console [

Hi I need to download the list of followers of a list of twitter users for my research. I am using c# code and I have visited the https://dev.twitter.com/console[^] which has as API to extract the associated number to each follower but not the exact Twitter ID which I require. Is there any one to help me
best regards
HDolat

推荐答案

下面是电子表格中用于获取Twitter关注者列表的一些代码.

Below are some bits of the code used in the spreadsheet, to fetch twitter followers list.

function tw_request(method, api_request){
  // general purpose function to interact with twitter API
  // for method and api_request doc see http://dev.twitter.com/doc/
  // retuns object
  var oauthConfig = UrlFetchApp.addOAuthService("twitter");
  oauthConfig.setAccessTokenUrl(
      "https://api.twitter.com/oauth/access_token");
  oauthConfig.setRequestTokenUrl(
      "https://api.twitter.com/oauth/request_token");
  oauthConfig.setAuthorizationUrl(
      "https://api.twitter.com/oauth/authorize");
  oauthConfig.setConsumerKey(getConsumerKey());
  oauthConfig.setConsumerSecret(getConsumerSecret());
  var requestData = {
        "method": method,
        "oAuthServiceName": "twitter",
        "oAuthUseToken": "always"
      };
   try {
      var result = UrlFetchApp.fetch(
          "https://api.twitter.com/1/"+api_request,
          requestData);
      var o  = Utilities.jsonParse(result.getContentText());
    } catch (e) {
      Logger.log(e);
    }
   return o;
}
function getFriendAndFo(sheetName){
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName(sheetName);
  sheet.getRange(2, 1, sheet.getLastRow(), sheet.getMaxColumns()).clear({contentsOnly:true}); //clear sheet
  var cursor = "-1";
  while(cursor != "none"){ // while twitter returns data loop
    try {
      var o = tw_request("GET", "statuses/"+sheetName+".json?cursor="+cursor); // note using sheetname to build api request
      var data = o.users;
      for (i in data){ // extracting some subobjects to top level (makes it easier to setRowsData)
        if (data[i].status){
          for (j in data[i].status){
            data[i]["status_"+j] = data[i].status[j];
          }
        }
        if (data[i].screen_name){ // also build url to jump to profile page
          data[i]["profile_link"] = "http://twitter.com/"+data[i].screen_name;
        }
      }
      var headRange = sheet.getRange(1, 1, 1, sheet.getMaxColumns());
      var rowIndex = sheet.getLastRow()+1;
      setRowsData(sheet, data, headRange, rowIndex); // dump data for this loop to sheet
      if (o.next_cursor!="0"){
        cursor = o.next_cursor; // get next cursor
      } else {
        cursor = "none"; // break
      }
    }  catch (e) {
      Logger.log(e);
    }
  }


操作,我将它变红了几次,但头顶上有很多问号在旋转.实际上,我正在寻找一种简单的API,该API可以帮助我将用户ID转换为屏幕名称.
顺便说一句,谢谢您的代码
Ops, I red it several times but there are many question marks rotaiting above my head. Actually I am looking for an easy API which may help me to convert the User IDs to the screen names.
by the way thanks for the codes


我认为这很有用!首先,我使用了 http://api.twitter.com/1/followers/ids .json?screen_name = username [ ^ ]查找上面用户名的关注者用户.然后使用 https://api.twitter.com/1/users/show. json?user_id =用户ID& include_entities = true [ http://api下载推文. twitter.com/1/statuses/user_timeline.rss?screen_name=屏幕名称和数量= 100& page = 1 [
I did some think which is useful! first of all I used the http://api.twitter.com/1/followers/ids.json?screen_name=username[^]to find the follower users of the username above. then used https://api.twitter.com/1/users/show.json?user_id=the users Id&include_entities=true[^] whicch has the screen name inside. It can be used to download tweets by http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=screen name&count=100&page=1[^] to download tweets
Thanks


这篇关于推特关注者列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆