Twitter follower/friend map


I seem to be getting into the swing of things with Yahoo Pipes at the moment and I seem to be creating lots of maps. Every time I use it, something else clicks in my head and puts a smile on my face. Yesterday, Aaron Tay asked me if I knew how to create a Twitter followers or friends map. I didn’t, but I thought it would be a good way to see if I could get to grips with some of Twitter’s APIs and also if they’d play more nicely with Yahoo pipes than previously. It was also nice to be asked by someone else to do something like this – my own projects seem to be a bit self-centred, so being able to do something useful for someone else made a nice change.

The Twitter API lets you pull out details of a users friends/followers. It does this via their Twitter id number, but by creating a URL with their id added to it, you can pull out full details. You can use a programming language to do this too, but if it goes into Yahoo pipes I’d rather do it there. Once you’ve got this, you can narrow the info down to the various bits you need. In my case I wanted biography details, location, photo and a link to Twitter profile.

In summary, I had to:

(1) Create user input boxes for ‘username’ and to identify if the map was for ‘followers’ or ‘friends’. This meant anyone can enter their user details, rather than just myself.

(2) I then had to build a url to point to the Twitter API and include the detail in (1).

(3) This url then fetched the details of the users followers or friends. ie their id numbers only.

(4) I then built another url using the id’s, to fetch full details of every follower or friend of the user.

(5) Each users profile contains a location field and if you put this into the ‘location builder’ module it extracts very detailed geographic location. Pretty impressive, considering some users only give the vaguest of details. It’s not perfect though, as, for example @therealwikiman is mapped to the USA, even though his location info is detailed. As he’s really based in England, I imagine the commute in the morning is a bit of a nightmare. 😉

(6) From various fields in each profile I then built a description that contained Twitter image, biography and location in text.

(7) I also added a link to each of their Twitter home pages.

(8) Finally I mapped all of the data to standard RSS/map data fields (title, link, description, y:location). When Yahoo pipes works with data it changes field names to reflect what it’s done to the data, so you need to change them to a format that is recognised.

(9) I connected it to the pipe output.

Twitter follower and friends map

When it ran, because it saw the field ‘item.y:location’ in there, it automatically displayed the information as a map, which you can see here. You can also add your own user info into the search box and create your own map. (NB: Sometimes Yahoo pipes & Twitter don’t play nicely together. If you have a problem with this pipe and have a Yahoo account, try copying the pipe and adding your own information into the search boxes.)

One thing I would like to get to grips with in Yahoo pipes is to be able to embed the output of a pipe into a web page and also allow users to add their own input on the same page, but I’ve not cracked that yet. So, if anyone else can help me with that side of things it would be appreciated. Thanks.


6 thoughts on “Twitter follower/friend map

  1. Gary Green

    This pipe only seems to work haphazardly. 😦 It seems to be a problem between Twitter & pipes. What a pain in the bum!!

  2. Gary, thanks for the effort.

    I feel terrible saying this but I found and (and probably more) which do what I asked more reliably. I also saw another yahoopipe

    I actually tweeted you ona whim, without doing any search. Then again I didn’t really expect you to charge off and do a yahoopipe so quickly 🙂 Hope you had fun playing with pipes though.

    This does illustrate the power of networking via social media though (which was the gem of the idea I had for a blog entry that led to this question about mapping), ask the right person and things can done before you even expect it!

    • That’s fine Aaron. I didn’t even bother doing a search for a Yahoo pipe either. I did look for a more professional map, but couldn’t find one, even though I knew there must be something. So many Twitter tools out there, but you can’t always find them straight away. I thought it was a nice challenge anyway. That’s what these sort of projects are about for me – part of a learning curve – I’d never pass them off as professional programming, just potentially useful. I’m just pleased when I manage to work out how these things work – using a Twitter API to call another API, pulling out images/biographies and putting them on a map with links back to Twitter. I am dissapointed though that it doesn’t work all the time. I played with it today using different user names and it was 50/50.

      Also, when I published my blog post about it on WordPress you get this handy feature that gives you links to related posts and sitting there right at the top when I went into the blog later to edit it, was the blog post you mentioned about the other Yahoo pipe. It’s actually interesting to see how the other pipe was created compared to mine. To be honest, even if I had seen this other pipe I would have probably tried to work it out myself anyway.

      • Aaron & Gary,

        I built the other pipe and it’s good to see that others following suit. You’re right that Twitter & Yahoo Pipes don’t work together too well – there are lots of rate limiting issues.

        It’s pretty easy to embed the pipe output into a web page – the input parameters are just passed into the pipe via the URL and Yahoo give you a “badge” of your map by embedding an iframe on your page.

        Have you also tried pulling out the KML feed from your pipe and pasting it into the search box of Google Maps? That’s quite fun 😉

        I’ll be looking into putting together another version of my map using Google’s Fusion Tables and Map API v3 – should handle a lot of twitter followers much more gracefully.

  3. Gary

    Thanks Andy
    I’ll have to try the KML feed into Google Maps idea – always like to play with these things.

    I’ve not done anything with Fusion tables or Map API. I’ll have to have a look at them – thanks for the tip. I’ve used Google docs to pull in a feed to a spreadsheet, but again it seems to have limits for RSS feeds. Not tried it with other Twitter APIs.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s