Exporting more friends or followers from Twitter to a Google Spreadsheet

Back in March 2011 I published Export Twitter Followers and Friends using a Google Spreadsheet. One of the problems with this solution is if you were trying to import a lot of friends or followers users would get the error message “Exceeded absolute-time timeout in milliseconds”. This is because there is a limitation to the amount of execution time each Google Apps Script gets.

Following feedback from users (the nature of my work is perpetual beta so if something isn’t working out for you just ask 😉 I’ve come up with a workaround. If you have already setup the original export friend/follower spreadsheet you need to open it and select Tools > Script editor… and paste the following code into it and save.

To use this new code you need to enter the following information directly into the script editor where prompted:

  • sheetName – sheet name you want to import the data to;
  • friendOrFo – whether you want ‘friends’ or ‘followers’; and
  • optScreenName – the screen name of the person

To run the script Run > getLotsOfFriendAndFo manually as many times as needed (the script will import 100 friends/followers at a time) or if you want to go away and make a cup of tea use Triggers > Current project triggers and add getLotsOfFriendAndFo as a time-driven function to run every minute (once you’ve finished your tea best to delete this trigger).

If something goes wrong during the import you can start over manually deleting any data and running resetGetLotsOfFriendAndFo (this resets the cursor used with the Twitter API).

Any additional comments welcome 😉

chevron_left
chevron_right

Join the conversation

comment 21 comments
  • Ryan

    When I run the this function I got an error,what is this about?
    ReferenceError: “cursor” is not defined. (line 493)
    This line is
    if (cursor != “none”){ // while twitter returns data loop
    in the getlot function.

  • Ryan

    I think the problem is the variable cursor below is not defined.
    if (!ScriptProperties.getProperty(“cursor”)){
    ScriptProperties.setProperty(“cursor”, “-1”);
    }
    if (cursor != “none”){ // while twitter returns data loop
    what is the string “cursor” in the setProperty line? Is it the variable cursor?

    • Martin Hawksey

      Hi Ryan – my mistake it should be if (ScriptProperties.getProperty(“cursor”) != “none”){ (basically the Twitter API returns a cursor position – the last batch of friends or followers – which is stored as a script property, which means you don’t have to get all friends/followers in one go). The maximum number you can get from the Twitter API is 100 so to get more keep running getLotsOfFriendAndFo() until you get everyone.
      Martin

  • Ryan

    How to get more than 100 followers each time?

  • Ryan

    Hi Martin, I know Twitter API only allow to GET 100 follower each time, but with your getFriendAndFo function, I could get more than 10000 followers until I get the “Exceeded absolute-time timeout in milliseconds” error, why is that?

    • Martin Hawksey

      @Ryan could be a number of things : Twitter API down, Apps Script glitch, spreadsheet is full.
      Martin

      • JW

        @Martin, if google docs only allows 400,000 cells in a spreadsheet, how can i get my nearly 100,000 followers in it? Can getLotsOfFriendAndFo also be set up 2 create new spreadsheets 2 fill?

        • Martin Hawksey

          @JW the best way to do it is once you get to the 400k limit
          make a copy of your original spreadsheet, then
          in your original make some more space by deleting all the rows apart from the header (you might want to select all, delete, then paste the header back in) and
          then start running the getLotsOfFriendAndFo function again
          Martin

          • JW

            How will I know that the function doesn’t just get the same friends each time?

  • Kevin

    Hi Martin, is there anyway to full the information faster then? instead of in 1 minute increments? At the current rate, it would take me 100+ hours just to gather the data for my current project.

  • Darcie

    Hi Martin,
    Thanks for this helpful tool. One question: When I import someone else’s followers, it gives me a list of 202 names when Twitter lists that she has 206 followers. I did a quick look through the list and saw two names that were missing that didn’t seem to have anything in common. Thoughts?

    • Martin Hawksey

      Hmm not entirely sure. Working on a new version. Fancy beta testing it?

      • Darcie

        Sorry this took me so long to get back to. I am trying v2 but am having trouble getting the sheet to populate with another person’s followers (I got my own to populate). It says “collecting data” and then it says the right number of followers but then I get this error: Oops The coordinates or dimensions of the range are invalid. (line 323)
        Any ideas?

  • christina

    Thanks for the great service, Martin. Is there a way I can configure your tool to pull members of specific Twitter lists?

    • christina

      And to add to previous question, these lists are not public and are my own lists.

    • Martin Hawksey

      Hi Christina – unfortunately I have implemented list import. You might be able to do this using the SocialBro.com app.

  • Charlie Screendrip

    Hi Martin,
    What an incredible tool. Really loving it. I am experiencing a similar problem to others above when trying to get followers/friends of other people.
    “The coordinates or dimensions of the range are invalid. (line 323)”

  • Jillian

    Thanks for this helpful tool, Martin!
    I’ve been able to set it up without any error messages, but had a question/suggestion for you (if you’re still monitoring this thread)!
    Is there any way to pull information like the date of the last tweet a user posted?
    Thanks for your help,
    Jillian

  • Walter

    Thanks for putting this together.
    I am getting an error about tw_request. I suppose this is because I don’t have the original code. Any way to get that?

  • Jose

    really really cool, I am also getting the same error a Walter with the tw_request, is there any way of making it work??
    THANKS

Comments are closed.

css.php