Export Twitter Followers and Friends using a Google Spreadsheet

Note: Twitter recently wrote to me reminding me that

methods of obtaining and exporting Twitter content obtained via the Twitter API is prohibited by section I.4.A of our API Terms of Service (https://dev.twitter.com/terms/api-terms ), specifically:

You will not attempt or encourage others to sell, rent, lease, sublicense, redistribute, or syndicate access to the Twitter API or Twitter Content to any third party without prior written approval from Twitter. If you provide an API that returns Twitter data, you may only return IDs (including tweet IDs and user IDs). You may export or extract non-programmatic, GUI-driven Twitter Content as a PDF or spreadsheet by using “save as” or similar functionality. Exporting Twitter Content to a datastore as a service or other cloud based service, however, is not permitted.

Following clarification from Twitter I making this template available again but please note.

By using this template you agree it is for personal use only and the data is not made publicly available.

Recently I’ve noticed a growing number of people arrive at this blog having searched for ‘export twitter followers’. Rather than them leaving disappointed here’s a Google Spreadsheet I threw together which allows you to grab a copy of your friends/followers:

*** Google Spreadsheet to Export Twitter Friends and Followers – NEW Version ***
Update 27/11/2014: This has been updated to a new version that uses the TwtrService Library (one time authentication)

Benefits of using Google Spreadsheet

  • Control – You register for your own API key with Twitter so you have full control of the account
  • Playing with the data – as you are importing straight into a spreadsheet you can do all of your own data manipulation like sorting, filtering and creating your own formula for things like follow/follower ratios
  • Backup – Google Spreadsheets allow you to download copies of spreadsheets in different formats
  • Share – You can make your lists of friends/followers easily viewable

Where’s this all going?

Having already done other things with the Twitter API and Google Spreadsheets (See Populating a Twitter List via Google Spreadsheet … Automatically!, Collect/backup tweets in a Google Spreadsheet, Google Apps Script, Spreadsheets, Twitter and Gadgets) the Twitter/Google Spreadsheet back is well and truly broken. You’ll probably see fewer posts one this area with new stuff instead I’ll probably start properly documenting the little code snippets I use (but if you have any interesting ideas you want help with get in touch).

This doesn’t mean I’ll be walking away from Google Spreadsheets. As recent posts like Turning Google Spreadsheets into a personal or group bookmarking service, show there is huge scope in using Spreadsheets as a very flexible rapid development platform.

Below are some bits of the code used in my new spreadsheet (all the code is viewable via the Script Editor in the Spreadsheet):

Update: This was the old way data was collected from the Twitter API

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;
}

Using the TwtrService Library it’s replaced with:

function tw_request(method, api_request){ 
  return TwtrService.get(api_request);
}

273 Comments




  1. Awesome. Used Ur link @ the top and it worked perfectly. Thanks!

    Reply

  2. Thank you for this tutorial! is there anything more simple that will just count the number of followers for a list of twitter accounts? not xml export, because google docs only allows 50 of these per sheet, i need a few more than 50…. any tips very helpful

    thank you!

    Reply


  3. Hey,

    Thanks for that, it works perfectly. I’m only having trouble to enable the other possible column headers in Advanced Options. Could you please help me?

    Reply

    1. Hi – it should just be a case of copying the names into a cell at the top of a blank column (unless twitter have changed the mapping)
      Martin

      Reply

  4. Hi! I’m trying to use your spreadsheet, but it fails. I copied both keys to the configure menu. After that, I click on “test connection” aand a msgbox replies “Authorization is required to perform that action.”. Do you know what could be working wrong?

    Reply

    1. Hi – in the spreadsheet of you go Tools > Script editor then on the dialog box that opens select Run > authorize this should valid your twitter account with the spreadsheet. You’ll then be able to run the sheet functions. Of not let me know ;)
      Martin

      Reply

      1. Hi, I am having the same issue but when I Run > authorize it tells me “Unexpected error: (line 566)”

        Btw it’s very generous of you to create and share tools like this, and to keep replying to poor sobs who ask you for help this far down the line! :) Thanks!

        Reply

        1. Hi Noah – haven’t been able to conclusively trace the problem but think google occasionally makes a bad copy that doesn’t handle authentication properly. Solution is to make a fresh copy of the spreadsheet and start again. Let me know if still a problem

          Reply

          1. I had the same issue (566 line error), however when I checked my OAuth Settings I noticed that I forgot to put a proper Callback URL, which should be: https://spreadsheets.google.com/macros

            Once I did that, saved it, and returned to the spreadsheet, I was able to select Tools > Script > Script Editor and then Run > aTest successfully. I also made sure I was signed OUT of Twitter before doing this.

            Hope this helps,
            Jon


  5. Hi – I really like your tutorial. The twitter stuff works well. Have you had success with facebook? I am trying similar approaches but haven’t yet cracked it.
    Thanks
    Luke

    Reply

    1. Hi Luke – not tried or seen anything yet but it an area I think I’ll be looking at in the next 3 months. If you beat me to it interested in how you do it ;)

      Thanks,
      Martin

      Reply

  6. Thanks for this!

    Any chance you’ve run into this error message when running the get others followers scripts? And if so, do you know of any resolution?

    Error message: “Exceeded absolute-time timeout in milliseconds”

    Reply

    1. hmm that’s probably what’s causing the problem. Need to see if there is a way to break the task up. Have to have a think short that one.

      Thanks for the feedback

      Martin

      Reply

  7. Hi, when I run aTest, I got an error “TypeError: Cannot read property “statuses_count” from undefined. (line 240)”, what is this about?

    Reply

    1. Hi Ryan – It essentially means that a connection wasn’t successful with the Twitter API (I’ve updated the script to catch this error better). In the Script editor if you run aTest then View > Log what message do you get?
      Thanks,
      Martin

      Reply

  8. Thank you Martin, I have sorted out, I entered the wrong consumer key. Also, I am wondering if twitter API allows me to extract all tweets from my followers and friends?

    Reply

  9. So, I’m Brazilian and not quite understand how it works, how to have a basic tutorial to show where I make my login, that holds the account you want followers, and so on. A hug.

    Reply

  10. Hi, Thanks for the apps. It surely helps a lot. One quick question though, how to add advance option in the spread sheet? Do we just add it in column header?

    Reply


  11. Awesome! I will give it a shot. Many thanks, going to have my students make use of this in the fall. It will be a great help! One last Q – any chance there’s a way to get friends/followers of more than one person at a time?

    Reply

    1. @charlton hmm it might be possible the main issue is you only get 350 requests to the twitter API per hour so you will need to do some load balancing (working on another project right now, will come back to this depending on demand)
      martin

      Reply

  12. Thanks a lot for this! Do you know if there is some easy way to turn this spreadsheet into a gdf-file or some other file that I can read into Gephi?

    All the best,
    Richard

    Reply

  13. @richard Gephi will accept a CSV input file. Simplest case is two columns, representing node connected to node. If you just open the CSV file in Gephi it will create the nodes and and the edges for you.

    Reply

  14. Thank you for the response, Tony!

    I will try that. Can I load additional information about each node from a separate file?

    Thank you for a very interesting blog!

    Richard

    Reply

  15. Awesome tool! I was wondering about exporting data from twitter lists in a similar way. That would be really useful to analyze selected groups of tweeps.

    Reply

  16. That’s a very interesting tool. However I haven’t been able to download the data as it says you cannot export data from external sources, and a list – also if managed by you – is intended as an external source. Nevertheless that’s a very nice desktop application, ty for sharing!

    Reply

    1. Didn’t know about the export limitations on SocialBro – thanks for sharing.

      Another tool I’m just about to write about is a MS Excel add-on NodeXL (only available for Windows PC). NodeXL is an advanced network visualisation tool so probably more than you need but it does have a built-in option to get list memberships (one of the Import options) which are saved to a spreadsheet (vertices sheet)

      Martin

      Reply

  17. I’m afraid I’m a Mac user but I’ll give it a try anyway on a PC. I have to say I’m interested in visualizations too and I’ve been playing with Gephi for several months. Although I’ve a background as a statistician I’m not a coder and one of my main issues has been data export from social networking services. And your blog has revealed to be very useful. Thanks!

    Reply

    1. @Angelo you’ll like my latest post then on NodeXL – Getting started with the @WiredUK friends network (no coding required ;). It’s a rerun of a Gephi recipe by Tony Hirst. It might be worth firing up the PC just to get the data and then export to Gephi. It is possible to run NodeXL on a virtual machine in Mac – you’ll obviously will need a copy of Win and Office though to do this).

      Thanks!
      Martin

      Reply

  18. Hi, I love the concept but when I run the aTest I get a pop-up on the spreadsheet that reads: “OOPS – it didn’t work” and when I check the log it reads: “Exception: Unexpected error:” Any suggestions?

    Reply

  19. This worked without a hiccup! Utterly amazed by the simple approach (using Google Docs) to get out info. I have been using Twitter Ruby Gem (it works too) but this was way simpler for many export tasks. Thanks a bunch.

    Reply

    1. @John – thanks glad it worked for you. Loads more other stuff you can do with Google Spreadsheets and Apps Script – its a great tool for rapid development ;)

      Reply

  20. Great work Martin, thank you! Easy to use and runs beautifully. Been looking for something like this for awhile now.

    If you do develop the spreadsheet to include list data as well, just a column saying which lists you have put them in that would be fabulous.

    Cheers,
    Mark.

    Reply

  21. Thanks Martin, this is amazing. Exactly what I needed. Great work.

    Reply

    1. Actually, I’ve suddenly got an error saying, “The coordinates or dimensions of the range are invalid. (line 204)” yet I haven’t changed anything in the script. Nothing works. Any ideas?

      Reply

      1. @Mitch sometimes this error is a temporary fault because Google servers are playing up. One thing you could try is open the Tools > script editor run one of the menu options then check View > log to see if it says anything
        Thanks,
        Martin

        Reply

  22. Thanks for this.
    However, when trying to authorize the spreadsheet with twitter, I did what you said Script Editor -> Run -> aTest (there was no ‘authorization’ function). I get the message saying ‘Apps Script – Oops. It did not work’. I’ve followed all the other steps and am not sure what is going wrong.
    I am running in Firefox on a Mac.
    Thank you for your help.

    Reply

    1. @John L I think its due to turbulence on either Google or Twitter servers preventing the spreadsheet to connect properly. Afraid I’ve got no better solution than trying again later
      Martin

      Reply

      1. I tried it again on a different day and time using Chrome instead of Firefox. Still had the some problem. Oh well.

        Anyway, thanks so much for replying. I really appreciate it.

        Reply

        1. Hi John and Martin,

          I just had the same problem with the ‘Apps-Script Opps’ message. I finally went to Tools -> Script Editor, Run -> Authorize and then it fixed the problem. I guess I must have missed that in the original instruction.

          Hope that helps for others with the same error message.
          Heather

          Reply

          1. ps this is absolutely awesome. I just downloaded 23,000 twitter followers of a company I want to analyze – amazing!


  23. Thanks a lot for your great job. I did everything as you explained above, and I have no error message at all.
    Nevertheless I can not find where is my list.
    I might sound stupid, but all I have is a small yellow message saying: “Running script getFollowers”
    I have more than 30K followers, and I guess it will take some time to show the full list, but after 2 hours, there is nothing else but the yellow message.
    Do you think I did something wrong?
    Thank you in advance for your help.
    Alix.

    Reply

  24. Wow, this is brilliant. Thank you so much. I was desperate seeing that tweetake.com was down. Rhis replaces it perfectly.

    Reply


  25. Whenever I run aTest, I get an error saying, “Oops it didn’t work” or “Opps, Authorisation is required to perform that actions” but it doesn’t give me the option to authorize it.

    Reply

  26. i don’t see authenicate, just configuration and get follows and friends types of scripts

    Reply

    1. Hmm there should be two athenicate functions in there (either will work) not sure why you can see other code and not these – usually if its a bad copy none of the code is there

      Reply

      1. I just deleted and made another copy of your spreadsheet. Still not seeing any athenicate functions.

        Reply

          1. Yes it is.


          2. Hi,

            The authenticate function is gone.

            I copied the spreadsheet a couple of times and saw same symptoms as Clay Hoffman.

            I reviewed the code of the script and it has no authenticate or similarly named function :-(


          3. Hi – I’ve put a new version of this spreadsheet up. It has improved code for getting the data from Twitter. If there are still problems let me know
            Martin



  27. I see the authorize script now, but when I run it I keep getting “Unexpected error: (line 580) Dismiss.

    This is whats on line 580-585

    var result = UrlFetchApp.fetch(
    “http://api.twitter.com/1/account/verify_credentials.json”,
    requestData);
    var o = Utilities.jsonParse(result.getContentText());
    ScriptProperties.setProperty(“STORED_SCREEN_NAME”, o.screen_name);
    }

    Reply

      1. Sometimes I think google doesn’t copy the authorisation tokens from twitter properly which leaves you in limbo with a half authenticated script. I’m afraid the only way I’ve found to get around this is to make a fresh copy of the template.
        Martin

        Reply

  28. This script is great, and I appreciate all the work that you have done.
    I looked through the comments, and it looks like other people aren’t having this issue, so I’ll see if I have something set up incorrectly. But, when I run the “getLotsOfFriendAndFo”, I get an error that says “ReferenceError: “users” is not defined. (line 172)”. Line 172 says: “var chunks = chunk(users,100);”. I am using V2 of the spreadsheet. I have tried on a couple of copies of the sheet. I am also trying to pull in someone elses followers. It works when I use the “get other persons followers” from the twitter menu, but it’s been timing out because of the volume. Any help would be appreciated, although I completly understand that you don’t want to spend a ton of time troubleshooting a free script you made.

    Reply

    1. Hi Joel – As you asked so nicely I had a look and there was a problem with the script. I’ve updated the code so if you grab a new copy of v2.1 it should work (fingers crossed – and if it doesn’t let me know ;)
      Martin

      Reply

  29. Martin, for advanced, do I just need to add the field name to a new column in the spreadsheet? I want to add

    follow_request_sent

    to my export. Thanks!

    Reply

    1. I think I’m actually looking for

      following_request_sent

      (the timestamp for the follow request YOU sent to a friend / someone you want to follow)

      I think follow_request_sent is the timestamp for follow requests from YOUR followers?

      Does the following timestamp exist?

      Reply

      1. Hi Jonah – you are right in that putting follow_request_sent as one of the headers means that data is populated. As you have probably discovered now this only returns true or false. The data returned by the bit of the API used in this solution unfortunately doesn’t include a following request timestamp (if this data is important to you, you might want to look at the socialbro.com app)
        Martin

        Reply

  30. Nice stuff, works like a charm!

    In order to visualize the network in gephi I’d like to also include the friends/followers relation among all friend/followers for a Twitter account. (Ie not get the complete list of all their F/F, but only the interconnection between the listed ones)

    Is this something you have looked at?

    Reply

    1. Hi Johan, I do have a script which constructs friend follow relationships but its very restricted in how many relationships it can manage (e.g. ignores relationships over 5000 and can only manage base networks of 300). What I’ve done in the past is use NodeXL. The import via twitter list lets you paste a list of username you want to get relationships for and generates an edge list, which can either be analysed further in NodeXL or exported to gephi)
      Martin

      Reply

  31. Hi Martin, how are you?
    I configured everything according to the steps and I have no error message at all, however, can not download my complete list of followers.
    After all set performing “getFollowers” and showed that first run in the bottom right a message 100 to 200 of 148000, but when he arrived in 4900 to 5000 of 148000 the system kept running and not download anything. I redid the process a few times and still managed to download about 26,000, but 122,000 still missing. I did something wrong? I left to do something? What do I need to get the 148,000?
    But without doubt the tool is fantastic!

    Reply

    1. Hi Almir, this tool is mainly geared around a 5000 follower max. There is a supplemental script in Tools > Script editor … called getMoreFriendsAndFollowers which can get more but is limited by the google spreadsheet maximum of 400,000 cells (with the number of columns used its around 40,000 twitter account details

      Reply

      1. Martin, thanks for the help. I looked in Tools -> Script Editor -> getMoreFriendsAndFollowers, but I found this script, it does not exist for me, at least by that name. For me there and getAnotherFollowers getLotsOfFriendAndFo. It is one of these two?

        Reply

          1. Hahahaha … okay! It happens. So, I tried that too, but does not return all my followers. He lowers 5000 and the first stop. Then re-run the scrip getFollowers and returns the message “Oops!
            Exceeded maximum execution time. “Then I ran the scrip getLotsOfFriendAndFo you said, but nothing happens. What is the procedure? I’m sorry to bother.


          2. To use this new code you need to enter the following information directly into the script editor where prompted in the getLotsOfFriendAndFo function:

            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


  32. Hi Martin, how are you? Happy 2012!
    Man, I’m picking up the same child to extract all the data. For this tool will be to extract that really gives my 150,000 followers?

    I was downloading the data and I returned the message limitation 400,000 cells from there I created a new worksheet and the worksheet name added to the scripts and getFollowers getLotsOfFriendAndFo script editor and yet the same message appears.

    Any other alternative?

    Hugs.

    Reply

    1. Hi when you reach the 400k limit make a copy of you original spreadsheet then remove the existing imported data and continue running the getmorefriendandfo script (you can rejoin the data by downloading as .csv and pasting together in Excel)

      Reply

      1. And clearSheet use the function to remove the data?

        Reply

        1. I just do what you said.

          Step 1: I ran getFollowers the first time and fell 5000 followers
          Step2: getFollowers ran a second time and fell over 5000 followers
          Step3: In the third execution getFollowers returned the message had reached the limit of 400k
          Step4: I made a copy of the worksheet and then it performed the function clearSheet to erase the data that had previously downloaded
          Step 5: Ran getLotsOfFriendAndFo, however, limit 400k message back to present, once again ran the function clearSheet and yet the message continued … ?

          Reply

      2. I just do what you said.

        Step 1: I ran getFollowers the first time and fell 5000 followers
        Step2: getFollowers ran a second time and fell over 5000 followers
        Step3: In the third execution getFollowers returned the message had reached the limit of 400k
        Step4: I made a copy of the worksheet and then it performed the function clearSheet to erase the data that had previously downloaded
        Step 5: Ran getLotsOfFriendAndFo, however, limit 400k message back to present, once again ran the function clearSheet and yet the message continued … ?

        Reply

        1. Guessing Google doesn’t realise the sheet has been emptied. When you get to step 5 and get the 400k message close the spreadsheet and reopen it – getLotsOfFriendAndFo should remember where it was up to

          Reply

          1. Martin, could extract here. Thanks again for your help! The tool is amazing!

            Where are you from? And it works with what?

            Hugs!


  33. Hi Martin,

    It is not working for me. Getting error “Oops! exceeded time”

    Also, can you please tell how to export it in excel

    Thanks,
    Sarath

    Reply

  34. Howdy Martin,

    First off, WOW! This is amazing.

    I’m running into one problem:

    I’m using the “Get other persons or followers” down the Twitter drop-down menu and it queries about 3400 users then returns this error:

    Oops
    The coordinates or dimensions of the range are invalid. (line 323)

    Thoughts?

    Reply

    1. So it appears the method for creating new sheets in Google Spreadsheets is currently borked, so I’ve come up with a workaround that fixes it. Use the original link at the beginning of this post to get version 2.1.2

      Reply


  35. I am also trying to download more than 5000. Everything seems to work except it keeps downloading the same set of 5000 over and over again. I rerun GetLotsOfFriendsAndFo and just keeps downloading the same batch. Hmm. Any suggestions.

    Reply

    1. Hmm not sure why this is happening. Important thing is to run getLotsOfFriendAndFo() from the script editor window. if you don’t this might send you into a loop

      Reply


  36. This is one of the neatest uses I’ve seen on Google Docs. I was about to sit down to rite API calls to pull lists of followers for a bunch of Twitter accounts, and instead came across this spreadsheet

    Great work!

    David

    Reply

    1. Hi,

      Please if this worked for you can you tell me how I can lay my hands on this with detailed instructions on how to make use of this?

      I need to get a list of all my followers for my two accounts.

      Thanks

      Reply

  37. Hello
    This is probably a silly question but when I try to get other person’s followers I get ‘This users account is protected. Data is not available’ however the Tweets are not protected. I’m guessing that I am missing something obvious. Please could you help me?

    Thanks for a great post – Very useful.
    Karen

    Reply

    1. Hi Karen – not you being stupid but me. There was a bug in a fix I made. If you make a fresh copy of version 2.1.2 (fingers crossed) it should work.
      Martin

      Reply


  38. Amazing! saved me a whole lot of time. Thanks!

    Reply


  39. Jon Thomas (@Story_Jon) You rock! The call back URL was the fix to help me authorize the app.

    Reply



  40. Hey, did you ever fix so you can download more than 5000 tweets? Mine isn’t working either, but great job making this, tho :)

    Reply

    1. @Morten it should be able to work with over 5000 but you need to configure the getMoreFriendOrFo() function in the script editor – there’s documentation on my site somewhere ;-s

      Reply




  41. This is a very helpful tool.

    For my study, I need to have not only the friends and followers of a specific screen name but also the ‘friend’ and ‘follower’ connections between those. Does anyone know of a script that will download this type of data from Twitter? I know that Is there a NodeXL provides this option but, unfortunately, it is extremely slow…

    Any help or guidance with this will be greatly appreciated.

    Thanks.

    John

    Reply


  42. Hi! When I try to load the Twitter menu, I get an error message Script function onOpen could not be found. Any suggestions? Thanks.

    Reply

      1. Yep, did that. More than once. Tried it in IE and Opera using different google accounts and get the same message.

        Reply


  43. Thanks for this great tool
    it really helped me a lot in colecting data. However, I’ve tried get other person follower but the max it could get is 5000 then i tried to do it again for the same person but i couldn’t. Plus, i’m afraid even if it did, it’ll get the same first 5000 again which wont be very helpful for me.
    could you plz let me know if there’s another way around it so i can get all the followers of another person
    again thank you for this powerful tool

    Reply

  44. Hi,

    I was confused about how to get other kind of data like the other column headers you mentioned. tried changing values in the sheet but got empty results.. so how exactly can one add other columns for the other values?

    Reply

  45. Thank you for this!!!

    Help, please. I need to use one of the advanced options but I’m not sure if I’m doing this correctly. I created a new column in the Followers sheet and named the header status_in_reply_to_screen_name . Am I missing something? Cos this method is not working for me.

    Reply


  46. Hi :). Is there a way to run the script again and only add new additions? Rather than adding the entire list again and having duplicates?

    Thank you by the way this has already saved me a TON of hours!

    Reply

  47. Hello, gone through the post and still didn’t see a means of extracting just my followers list. Anyhow anyone can help with that for me? Thanks

    Reply

  48. Hi Martin – a question for you a bit off topic here. Twitter’s data column gives a date/time value. Do you know of any easy way to convert that (from Excel) to a time interval such that it can be used for dynamic analysis?

    Many thanks,
    Charlton

    Reply

  49. Such a shame they made you remove this sir – used to be an excellent tool!!

    Reply

  50. Hi Martin, your script is awesome and I got it working in the end, but with a little glitch. I suggest you amend the instructions:

    Step 4.5 While in the Script Editor mode, select Run > authenticate

    Step 6.5 Back in the excel file select Twitter > Test Connection – you should get back a message stating “Connected to Twitter Successfully”. If you do not get this message, check to make sure you have the call-back URL filled in on our Twitter App Settings – make your call-back URL the same as your website URL even if its a fictitious one for the time being

    Reply

  51. Thank you! I’m also searching for a way to get emails of all my twitter followers. I can create a new landing page, but it will be much time consuming.
    Well thanks!

    Reply



  52. I keep getting a
    APPS Script
    OOPs it didn’t work message

    any ideas?

    Reply

  53. If the user has more than 100k follower, how to get only the first 5000 follower ?

    Reply

  54. Got some difficulties (wanted to go too fast…) but coming back to the tutorial everything is well documented.
    Did not work in Opera, worked fine in Chrome.
    Awesome result.
    Thanks Martin !

    Reply

  55. Amazing script! This is exactly what I was looking for. Thank you for putting it together. Love the ability to add columns.

    Reply

  56. Request failed for returned code 410. Server response: {“errors”: [{“message”: “The Twitter REST API v1 will soon stop functioning. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.”, “code”: 68}]} (line 585, file “Twitter Script”)

    Reply

  57. I am getting an 410 error when running the Authenticate function

    Request failed for returned code 410. Server response: {“errors”: [{“message”: “The Twitter REST API v1 will soon stop functioning. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.”, “code”: 68}]} (line 585, file “Twitter Script”)

    Reply

  58. The spreadsheet has not retrieved any followers since the migration to the API 1.1. Will an updated version that interacts with the new API be available at some point?
    Thanks a lot for this, it is a great tool!

    Reply

  59. I fixed it – go to script editor and “find” all instances of “/1/” (there should be 2) and “replace” with “1.1”. Tada!!!
    jules:)

    Reply

  60. Jules–thanks, I actually noticed that someone has updated the code in the public Google Spreadsheet file. However, I am still having problems getting it back to work. Have you been able to use it and regularly download data in the current version?

    Reply

  61. Jules, I think something may have changed. When I run the script, it now says that there are no new users. Did someone change the script on the public spreadsheet.

    Reply

  62. Thanks Martin–it does work fine now!

    Reply

  63. What a great spreadsheet Marting! Question, can it be modified to get the time of the last tweet?

    Reply

  64. Sorry about the extra “g” in Martin.

    Reply


  65. Hello, I was wondering what a callback URL is? what do I use for that.
    thanks

    Reply

  66. can i get the emails of my followers through some API call? Is that facility availble on twitter? I am urgent need of it.Any way or any link

    Reply

  67. In theory Martin would it be possible to create something similar to this, but set it to grab via location? For instance, list all my followers in London UK?

    Reply


  68. I am getting error when I run aTest ” OOPS-it didnt work..” . I am missing something

    Reply


  69. Brilliant stuff, thanks a million!
    Now if only there was some way of making it send DMs – I’m not a spammer, I run the twitter account for a local group and could do with advising our followers of new campaigns a few times a year.

    Reply

  70. I just want to say, thanks a lot man. You script is working like a charm! Now i have my own app on Google drive to analyze my twitter account.
    Thanks again, you rock :)

    Reply

  71. Thanks for this! This is why I love Google Apps… been searching for a way to download a csv file of my followers with no luck & then thought maybe Google Apps? Would it be OK to link back to this article from my blog?

    Reply

  72. HI Martin. I’ve used this before you received the Twitter admonition. Glad to see it’s Back. Is there still way in the new version to search for Tweets with other search operators – hashtags, keywords, etc.? Or will this only do friends/followers data?

    Many thanks!

    Reply

  73. It looks so nice, but somehow I do something wrong. When I run “authorize” I am running in an error at line 585. Can somebody please explain. I am just doing whats instructed, I do not have experience with these kind of interfaces, but I really looooveee the functionality.

    Reply

  74. Hi I tried to configure the twitter API using the instructions below but it keeps telling me that I have an invalid URL formate to do it…any help would be appreciated! Thanks!

    1. Register for an API key with Twitter at http://dev.twitter.com/apps/new (if you’ve already registered a Google Spreadsheet/Twitter mashup you can reuse your existing Consumer Key/Consumer Secret). In the form these are the important bits:
    – Application Website = anything you like
    – Application Type = Browser
    – Callback URL = https://spreadsheets.google.com/macros
    – Default Access type = Read-only
    2. Once finished filling in the form and accepting Twitter’s terms and conditions you’ll see a summary page which includes a Consumer Key and Consumer Secret which you need to enter below
    3. When your Key and Secret are saved you need to open Tools > Script Editor … and run the ‘authenticate’ function

    Reply

  75. You are an absolute GENIUS. Thank you so much! Your directions were also tremendously clear for someone like me who knows nothing about scripts or code and super easy to follow. Thanks again!

    Reply

  76. This is an awesome app.

    I’m trying to use the ‘GetLotsofFriendAndFo’ function and I’m running into a problem mentioned above, but I don’t see a solution.

    The first time I ran it, it asked for the user etc that I wanted to target. Since then though that same form has not reappeared, so every time I run it it downloads the same users. I’m not even totally convinced that the users it’s downloading are of the account I originally put in.

    Any way around this? A way to reset it perhaps, or to see what account it’s targetting?

    Reply


  77. Hi, good script!
    One question for you: getting the followers of another user (about 9000) i can obtain always the first 5000. Why? there is a way to obtain the remaining followers?

    thanks a lot

    Reply

  78. Hi Martin,

    Thanks for providing this! When I try to Run: Authenticate I get this error: OAuth Error (line 585, file “Twitter Script”)

    Would love any assistance with this :)

    Cheers,

    Kim

    Reply

  79. Hi, i know that you have to give permission and others can automatically look at your documents- I got up to the point that said run atest and found that two other who were not identifiable had revised the script in that time and also it said the test failed too! Any help ? Slim chance I know. Also any idea of what those people might have done as i was logged in via my personal account!

    Thanks-

    Reply


  80. Hi. I’m not at all technical but followed your instructions and exported the data that I wanted first time. Thanks v much for building this sheet – much appreciated :)

    Reply

  81. Hello! I was able to retrieve all the followers of my account and am trying to get all the followers of my followers. It seems that I am able to do it by manually entering the username of the user whose follower’s I am interested in. But I am looking for followers of all my followers and manually entering each one would just not be feasible. Is there any work around for this or any script that I could run which gets me the data?

    Thanks

    Reply

  82. If it worked for me, there is hope for anyone. Thanks Martin. I take it that there is no way to get email, phone number or to separate the name as “First name” “Last Name”

    Reply


    1. Just downloaded Version 3.0 but I’m getting an error:

      ScriptProperties API is deprecated.
      File: Twitter Script Line: 175

      What should I do?

      Thanks.

      Reply

  83. Downloaded version 3.0. Getting the following error:

    ScriptProperties API is deprecated.
    File: Twitter Script Line: 175

    Thanks for all your hard work!

    Reply

  84. Find the spreadsheet seems broken. I get the following error: There was a problem
    Script function setup could not be found!

    Reply

  85. running the newest version, I get this error message when I try Twitter>Configure: :”Script function setup could not be found”

    Any ideas?

    Thanks!

    Reply

    1. When you open Tools > Script editor in your copy is it version 3.0.2? It might be that you got a duff copy in between updates. I’ve just tested and the setup runs fine

      Reply

      1. I’m having the same problem. Everything under the Twitter pulldown returns “Script function could not be found” (with the name of the particular function included in the error message). I am using a fresh copy from version 3.0.2.

        Reply

      2. Haha. Those error messages have stopped. Now I’m just getting the “no new users” messages.

        Reply

  86. should the get other persons friends/followers work? I can get my friends/followers no problem, but when I try the others the tab pops up that says looking for data, but then doesn’t return anything after that.

    Thanks!

    Reply

    1. ok – so looks like there were a couple of things to fix. Updated now to version 3.1 (fresh copy of the template required). This update should also fix getting other data like status_created_at into the sheet)

      Reply

      1. I can’t figure out what I’m doing wrong. I opened your sheet, made a copy, then selected “Test Connection.” Initially it doesn’t work but if I wait about 30 minutes, the connection tests successfully. However, none of the functions to get followers work for me. They always return “All done – no new users.” I’m using version 3.1. Any suggestions?

        Reply

        1. So not even getting your own followers works? You can try Tools > Script editor and Run > getFollowers when it finishes you can View > Logs to see if any errors have been thrown

          Reply

          1. Looks like you haven’t run Twitter > Configure from the sheet. If you run this what does it say?


          2. I’ve been using your sheet for about a year. It stopped working recently. When I select Test Connection, it always says I’ve successfully connected to Twitter but all the functions return “No new users”. When I select Configure, the API fields are empty (though I registered a long time ago). When I click the registration link you have in the instructions, it takes me to a page that says Access Denied.


          3. I created a new API Key. All is working again. Initially couldn’t get 3.2 to accept the Key (nothing would happen when I clicked the Next button). Went back to 3.1 and was able to enter it there. Now the saved API works with 3.2 Thanks again for all your work!!


          4. Thanks for your reply Martin ! I managed to go a bit farther… I have my api key and secret. But when I put it in the configure section of the spreadshit, I can’t click on next… The only solution I have is quitting. Then, if I run the Get followers or Get friends nothing happen. But this is normal i guess since I did not manage to validate the previous step. If there any chance you can help a bit more, i’d be very grateful :)


          5. there was a bug with the next button which is fixed. Take a fresh copy of the template and you should be able to set it up properly


          6. ah – okay found and fixed a bug that prevented the next button working
            Thanks
            Martin


          7. Yay, well done Martin, it workd fine ! And it was super easy. Cheers !


  87. Hi Martin, Thanks for this tuto but I cannot run it correctly for some reason (I am not IT at all, more marketing like..). I have the twitter tab, when I click on configure, I get an error “cannot find the function of Script set up”. Not sure where to find the key and and Secret Twitter then… Can you help?

    (OMG, you’ve been commenting on this for the last 3 years… impressive!)

    Reply

  88. Firstly thanks for the spreadsheet and supporting it for so long.

    Question for you, i’m looking to come up with a simple method (that i can set up and walk away from) to export the follower_count and statuses_count for 10 different twitter accounts, While i can get this info using “get other followers” account by account on your spreadsheet I am then faced with a tonne more info than is required (all the followers details). Not the end of the world but running this on 10 accounts, all with 3000+ followers takes quite some time.

    I was wondering if i achieve this by scripting in a “Get Following” option to return only the details on the 10 accounts i follow, would this be against the twitter api terms and conditions (the reason i assume a function like this is not already included). Any info on this would be much appreciated.

    (I realize that i could achieve what i’m looking for by having the 10 accounts follow one specific account i’d set up for only this purpose but i could see this causing me future issues due to having no real control over who is following the account.)

    Thanks again.

    Reply

  89. Hey! Thanks so much for supporting this. Is it possible instead of using the url field, it can use the expanded_url field? Right now the urls are the t.co short links that mask the url that appears on the users profile (or when the link is resolved).

    Reply

    1. It is possible but you’ll need to modify the code in Tools > Script editor. Look for lines (two occurences) that include TwtrService.get("users/lookup" and in the for loops after them add the line before the data.push with o[j].expanded_url = (o[j].entities.url) ? o[j].entities.url.urls[0].expanded_url : null; (in the second instance replace the o with d e.g. d[j].expanded_url = (d[j].entities.url) ? d[j].entities.url.urls[0].expanded_url : null;. Finally add a column called expanded_url

      Reply

  90. Works beautifully several times over! Thanks for devoting so much time to making this work.

    Reply

  91. Thanks Martin. Fantastic! It’s just what I needed to sort out my contacts and keep track of my direct Tweets.
    In case it helps anyone who is not familiar with API registration, the ‘API Secret code’ is displayed on the ‘Keys and Access Tokens’ page of the Twitter Application Manager.

    Reply

  92. Hi Martin,
    Forgive me if I am being stupid but is the data available to be able to add a column showing the Twitter profile url for each contact? I would like to be able to click on a link in my spreadsheet that would then allow me to go to a Followers Profile page, so I can then send them a Direct Tweet.
    Kind regards
    Mike

    Reply

  93. Hi Martin, I used the older version a few months ago and it worked a charm, really grateful thanks. However it stopped working today so I had a look at this blog and noticed it has gone up to v3.2. I’ve downloaded it and done all the setup but it won’t function for me.

    I’ve authenticated etc and done a ‘test connection’ to see message Connected to Twitter sucessfully with XXXXXXXXX

    However when I run ‘get followers’ or anything else I see the message ‘Looking for data…’ for about 3 seconds, it disappears and nothing happens. Any tips? Thanks in advance

    Reply

  94. Hi Martin,
    Thank you so much for this app. I’m using it to collect data on other users’ friends for a network analysis and it worked wonderfully 93 times (i.e. for 93 Twitter users), but I seem to have hit a wall. I’ve re-copied the doc, used a different Twitter key and secret, used a different gmail account’s drive, and waited for a few days between tries, but it’s no longer returning the data. The script will start to run but then will just time out. Do you have any suggestions? Thank you so much in advance!
    Diana

    Reply

    1. In the spreadsheet if you open Tools > Script editor and Run > one of the functions one of the other drop down menu options is to View > log (or something similar) this may reveal more about where the script is going wrong

      Reply

  95. Dear Mr. Martin
    Thanks for creating such an amazing application. I have a question with regard the usage capability of your tool. I have a list of more than 1000 usernames/screen names of twitter users and I am interested in collecting their friend info only. I know your tool can do that, but I have to type each person name to get their information. The question is can I supply your tool somehow with the list of the users and it collect the data instead of typing in one user a time? any help is appreciated in advance as this will be used in my research and a citation to your tool will absolute be provided in my research.

    Best
    Samer

    Reply

      1. Hi Martin, Thanks for the reply. I know twitter have this restrictions but I was wondering if there is a way to make it automatic i.e. like NodeXl which collect data then wait some times then collect data again. I used NodeXl and provided it with a list of users which gave me all the info I was looking for but the problem with NodeXl is slow and give me more than what I am looking for. If it is possible to do the same task with your tool how can I do it please?

        Reply

        1. Also, if I have the list of users how can I provide them to the tool. I tried copy pasting some users but I end up with an error.

          Reply

        2. Out of the box this tool wouldn’t do it and would need extra code. If the extra code was added I don’t think it would be any quicker than NodeXL as it uses the same Twitter data points with the same restrictions

          Reply

  96. Hi, I have used your spreadsheet many times and has always worked perfectly, but now I am having problems. When I try to authenticate after entering my API credentials I get the following error message: “TypeError: Cannot call method “getRange” of null.” I have tried with three different browsers and three different Twitter apps but the problem will not go away. How can it be solved? Thanks!

    Reply

  97. Dear Martin!
    First of all: Thank you so much for your work! The spreadsheet already saved me tons of time (or money). :)
    I do have a little problem with the advanced options. I added a column in my spreadsheet with the followers by another Twitter user and tried to reload the data, but the columns stay empty no matter what I do or how Ilong I wait. Am I missing something? I just need to get the URL to the follower’s profiles and I’m the happiest employer on the world today. :)
    Thank you, thank you, thank you and sunny greetings from Germany!
    Anne

    Reply

    1. To get followers of another user you need to use the menu option … or am I missing your question?

      Reply

      1. Hi Martin!
        I managed to get the data for another Twitter user, and I also added columns for example for verified/not verified. But it seems to be the case that the column for the link to the user profile does not work properly. The data does not load.
        Besides that everything is great! :)
        Thank you
        Anne

        Reply

  98. Martin,
    Wanted to be sure to Thank You for making this product. It has saved me a ton of time. I was on a mission to figure out how to get followers/following from a twitter account when I ran across your template. It would have taken me many hours to figure out how to do this. You made things so much easier.

    I’m not sure if I saw this mentioned somewhere in the comments or if you’re aware it does this, but before trying your getlotsofFriendsorFo script, we decided to run that same spreadsheet name again for an account that has 15k followers. To our surprise your coding remembered the twitter cursor and bought back the rest of the records in 3 batches. I’m sure using your getlotsofFriendsorFo script would be beneficial for larger accounts resulting in less batch runs, but this was Outstanding!

    Thanks again,

    Reply

  99. Hi, thanks for what seems to be a great tool!

    I’ve tried following the steps, but when it attempts to authorize my Twitter account it says that “Having multiple Google accounts will interfere with the authorization” (paraphrased). It suggests opening an Incognito window, but when I run the script there I get the same results. I can’t get through that screen to the next step.

    Also, what steps are needed to completely uninstall everything once I’m done?

    best
    John

    Reply

    1. I have this same problem too. Is there a way to fix this?

      Reply

    2. What browser version are you using? Multiple google accounts aren’t an issue if you are running the script against your default account.

      I’ve added a menu option to disconnect twitter access. Take a fresh copy of the template to use it. As personal access details are stored centrally running this in one sheet deletes details for all (I should add the way access details are stored means as the project owner I have no access to them, they are stored by Google associated with your user account)

      Reply

      1. Hi Martin,

        I am using the latest version of Google Chrome [Version 42.0.2311.90 (64-bit)].

        I couldn’t get your Spreadsheet to work, as mentioned in my previous post.

        Reply

        1. ah – think I’ve spotted the problem. There were some changes Google made that I didn’t push to this version. If you take another copy of the template (sorry) it should work.

          Reply

          1. I’m having the same problem with the 3.2.2 version. Did this get resolved? I’ve tried with different browers and making new copies of the google doc. It seems to hang up on that “multiple accounts” page and doesn’t move on.


  100. Thanks for sharing this. I’m not a programmer (and don’t even play one on TV), so there is no way I could have done this myself. (Well, I suppose if I spent a few months learning to code…) You’ve saved me a ton of time. Thanks again!

    Reply

  101. Hi Martin,

    Thank you for your tool, the instructions were very easy to follow!

    However, it pulled 5 times as many followers then we actually have. What could be the reason for this?

    Reply

  102. This tool has been working very well — until a few days ago. Suddenly it has started to pull many duplicate records, etc.

    Reply

  103. Can this be tailored to export all tweets you have favorited along with the username of the person who posted the favorited tweet? Thanks!

    Reply

  104. Hi!
    Thanks a lot for your work!
    I have a question/problem.
    I want to extract lots of followers from an account, i try this:
    If you get a ‘Exceeded absolute-time timeout in milliseconds’ error message there is a manual function in the script editor called getLotsOfFriendAndFo(). To use this clear any existing data imported to the particular sheet and enter the following details into the function in the script editor:

    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 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).

    With NO results…
    This:
    sheetName – sheet name you want to import the data to;

    Its a new spreadsheet created in google drive or what?!?

    Reply

    1. you need to be a bit more leisurely – twitter rate limits this data. I can’t recall the actual limits (might be captured in the comments), but running every 15min should do it

      Reply

  105. Hi,
    I love the concept of this tool! I’m a beginner trying to follow your instructions… I get to the point of creating my twitter application and can’t go any further because the following error message appears:

    Error
    The client application failed validation: Not a valid URL format

    I think my issue is that I don’t fully understand what I am being asked for here, but can you help explain please so that I can create the required coded to continue?

    Many thanks
    Lizzie

    Reply

  106. Hi, sorry if I’m missing something, but I’m trying to grab a list of another user’s followers. It works at first then times out after successfully grabbing 5000 followers. It tells me to run it again to get the rest (a further 3000 ish), but nothing happens when I do – can’t get those last 3000. Any tips?

    Many thanks

    Alex

    Reply

  107. hi,
    your script is not working anymore: trying to get other persons followers I get this error message: “Script is using OAuthConfig which has been shut down. Learn more at http://goo.gl/IwCSaV
    The version I’m using is 2.1.2
    Thanks

    Reply

      1. Thank you for the update! I also just moved up from 2.1.2.
        Very much appreciated.

        Reply

  108. im having an issue with downloading once over 5000, like mentioned i use the script editor and i manage to get on occasion around 20k on one sheet, i copy what i have into my excel sheet, clear the current sheet and reload the page, i then run script again, it says it downloads them and no errors come up and all the extra cells are there so the row goes down to about 20-30k, or more depending on how many times i run it, however not data is showing in any of the cells?

    Reply

  109. Hi Marti, thanks for sharing this hack.
    I’ve tried following the steps, but when it attempts to authorize my Twitter account it says that:

    “Twitter Authorisation
    Please be aware that if you are logged into multiple Google accounts authentication may fail. You can either log out of other Google accounts or use an incognito window.

    “Oops something went wrong. Twitter says: Desktop applications only support the oauth_callback value ‘oob’ /oauth/request_token”

    Can you help me to resolve it?

    Thanks.

    Reply

    1. Same. Anyone know how to fix that?

      Reply

  110. Just wanted to say a big thanks for sharing this. Really useful and easy to use (even though I did get it wrong a couple of times – user error though, not your fault!)

    Reply

  111. Hello,
    I wanted to try your last script before use the manual function (the first doesn’t work even with your instructions) but the connection with Twitter didn’t work.
    I try the test Twitter Connection and I got the message “Ooops It didn’t work.
    But I was connect with my Twitter account.
    What could be wrong please ?

    Reply

  112. Very useful, thanks for sharing this.
    Are there any functions available to export Twitter list members?

    Reply

  113. Thank you so much ! Great help and so easy to use !

    Reply

  114. For anyone getting the following error:

    “Oops something went wrong. Twitter says: Desktop applications only support the oauth_callback value ‘oob’ /oauth/request_token”

    You need to edit your Twitter Application and add in a Callback URL. For the sake of simplicity, just use a localhost address: http://127.0.0.1:4000

    I did this and the script worked perfectly!

    Reply

  115. Hi.
    Thank you for sharing this hack, it has been very useful.

    Lately though I often encounter an error with big accounts (account with really many followers).

    The script freezes after it adds rows in the spreadsheet and throws an error:
    “TypeError: Cannot call method “join” of undefined”

    I suspect it may be due to very long user ids twitter now uses. It seems to me that there is a problem with lookup function of these ids but I am not sure where.

    I tried to add a line in getLotsOfFriendAndFo function “params.stringify_ids = “true”;” but this didn’t solve the issue.

    Using logger I can see that now user_id param is displayed correctly but the problem persists.

    I suspect it may be due to big accounts having many new users with long user ids. I don’t get this problem with relatively smaller accounts but still well over 5000 followers.

    I would very much appreciate if you could find a way to fix this

    Reply

    1. The script stringifies id numbers too big to be used as arguments and those are lost. I have 124 followers. Martin’s script gives me 122. I’ve tried to get my followers through Twitter’s console https://dev.twitter.com/rest/tools/console and it gives me two more, which are the only ones that have the new, long id number. They don’t appear among the 122 the spreadsheet shows.

      I would appreciate that this is fixed too. I’ve been trying for hours to no avail. The problem is well explained here: https://dev.twitter.com/overview/api/twitter-ids-json-and-snowflake

      Thanks!

      Reply

      1. I don’t think this is a problem – the sheet already uses id_str referenced in the link provided. Andres if you can provide your twitter screen name I can look into further

        Reply

  116. Is there a way to extract the email addressed from this google spreadsheet?

    Reply

  117. re: advanced settings – adding a column header doesnt seem to be working for me.

    Added Column “O” (after N) included fx profile_link.. hit getfriends again and I get errors. It adds 5 new users each time but they are 5 blank lines.

    TypeError: Cannot call method “join” of undefined. (line 484, file “Code”)

    I tried in Chrome and in IE but get both browsers get errors.

    ps. other than this issue.. it works great and I love it. : )

    Reply

    1. I’ve just started getting the same error code … very frustrating!

      Have you managed to get it to work?

      Reply

      1. looks like Twitter have changed this – using a column name `url` will return a shortened version of a profile link. To get the expanded version required an edit to the code, but if you take a fresh copy of the template profile_link should be working again

        Reply

        1. When I try and run the ‘Get Followers’ for a second time to pull additional followers I’m receiving the ‘TypeError: Cannot call method “join” of undefined.’ Error … Any ideas??

          Reply

  118. Hi, I’ve been using this tool pretty reliably, but the last few times I’ve used it, it’s given me the incorrect number of followers.

    When click “get another person’s followers” and input the screenname, it collects the data and roughly shows the right number of followers. However, when it says that it’s inputting the number of followers into the sheet, it’s a lower number. So the account has 700 people, it says it’s located 700 people, but only puts in 650 into the sheet. Is there any way I can deal with this?

    Thanks!

    Reply

  119. Hi there, the tool isn’t downloading the right number of followers. It identifies the correct number of followers when it’s gathering the data, but when it actually inputs it into the excel sheet, it misses quite a few.

    For example, the account has 700 followers. The tool identifies this but then only downloads 650.

    I’ve tried this with other accounts and it appears to have the same issue. Any help?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *