Some Twitter code (Warning, coders only)

So in a previous post I promised to share the code that lets me keep track of the people that actively engage on Twitter – that reply or retweet. As I promised that six months ago I thought it was time to dig out the code. It’s relatively straightforward, mostly because I use the Twitter4J library to do most of the heavy lifting. Hope this is useful for someone.

If you are willing to do some coding, here is how it would work in java…

package twitone;

import java.util.ArrayList;
import java.util.Map;

import twitone.structure.BaseTwitterClass;
import twitone.structure.TwitApplicationFactory;
import twitter4j.Paging;
import twitter4j.RateLimitStatus;
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;

public class MyRetweeters extends BaseTwitterClass {

  private Twitter twitter;

  public MyRetweeters(Twitter twitter) {
    this.twitter = twitter;
  }

  public static void main(String[] args) throws TwitterException {

    Twitter twitter = TwitApplicationFactory.getjoereddingtonTwitter();
    MyRetweeters unit = new MyRetweeters(twitter);
    String temp[] = unit.get();
    for (String string : temp) {
      System.out.println(string);
    }
  }

  public String[] get() {
    ArrayList names = new ArrayList();
    try {
      for (Status status : twitter.getUserTimeline(new Paging(1, 200))) {
        System.out.println(status.getText());
        if (status.getText().startsWith("RT")) {
          // skip
        } else if (status.getRetweetCount() > 0) {
          // Because I don't want to breach
          // Twitter's rate limits
          // okay the below has been added to keep within the rate
          // limited.
          waitUntilICanMakeAnotherCall();
          // end keeping within rate limit code.
          for (Status rt : twitter.getRetweets(status.getId())) {
            names.add(rt.getUser().getScreenName());
            System.out.println("---" + rt.getUser().getScreenName());
          }
        }
      }
    } catch (TwitterException e) {
      e.printStackTrace();
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    return names.toArray(new String[names.size()]);
  }

  /**
   * @throws TwitterException
   * @throws InterruptedException
   */
  protected void waitUntilICanMakeAnotherCall() throws TwitterException, InterruptedException {
    {
      Map<String, RateLimitStatus> temp = twitter.getRateLimitStatus();

      RateLimitStatus temp2 = temp.get("/statuses/retweets/:id");
      System.out.println(temp2.getRemaining());
      if (temp2.getRemaining() == 0) {
        Thread.sleep((temp2.getSecondsUntilReset() + 5) * 1000);
        return;
      }
      System.out.println(temp2.getSecondsUntilReset());
      int secondstosleep = 1 + temp2.getSecondsUntilReset() / temp2.getRemaining();
      System.out.println(secondstosleep);
      Thread.sleep(secondstosleep * 1000);
    }
  }
}

This code will print out every tweet you’ve made recently, along with the IDs of the people who retweeted it. A couple of quick things to note – mostly that this line:

Twitter twitter = TwitApplicationFactory.getjoereddingtonTwitter();

won’t work for you – that’s me getting my own API key and so on, you’ll have to write your own…

You should also know that this only works on the last 200 tweets, largely because that’s all I ever needed, it would be fairly simple to loop over the pages.

If you want replies rather than retweets, that’s actually much quicker and easier:

private String[] getReplies() {
		ArrayList names = new ArrayList();
		try {
			for (Status status : twitter.getMentionsTimeline(new Paging(1, 200))) {
				if (status.getInReplyToStatusId() == -1) {
					// skip, possibly/likely spam, I'll pick up the genuine
					// ones by hand
				} else {
					names.add(status.getUser().getScreenName());
				}
			}
		} catch (TwitterException e) {
			e.printStackTrace();
		}
		return names.toArray(new String[names.size()]);
	} // TODO Auto-generated method stub

Link roundup, part 2

In March I wrote a blog post where I collected together all the links I’d recently shared on social media. I think a lot about how I use things like twitter – I want to make sure that I’m providing useful, or at least interesting information to people. I would like to think I’m making the world a tiny bit better not a tiny bit worse. I got some very good feedback about the last post and so I thought I’d continue on with the process…

So let’s begin.  Over the last few months I’ve been tweeting about:

General Disability:

Disability stories that made me angry (warning: rage-inducing)

Funny…

Internet and data-freedoms:

Misc:

A controversial former Tory councillor who claimed to have slept with an Arsenal striker and alleged that Ted Heath was gay and went “cottaging” before becoming prime minister lost his seat on Barnet Council, winning just 265 votes.

Self-styled “King of Bling” Brian Coleman once served as chairman of the London Assembly and was a Conservative councillor in the borough before being suspended after assaulting a woman who filmed him breaking parking rules.

He had kept his seat as an independent after the incident.

So that’s my catalog of interesting things for the last couple of weeks.

That didn’t work (Twitter edition)

Well I’ve screwed that up…

Screen Shot 2014-01-04 at 18.19.55

So at the start of the year I wrote the following:

So in the New Year (I’ve largely started already) I’m going to try and resolve these. Firstly, I’m going to wholeheartedly embrace engagement. There are a couple of changes here. Over the last year I’ve periodically gone on unfollowing rampages to try and keep the information flow fresh. People view unfollowing in all sorts of different ways on Twitter and it’s clearly not conducive to engagement. So I’ve been writing some code (which I shall post at a later date because this is already quite a long post) that will keep track of the twitter ID of everyone who replied to me or retweeted me – that way I should avoid any accidental unfollowing of that group of users.

So the two pledges here are:

  • I pledge no unfollowing of engaged users
  • I also pledge to reply at least once to everyone who messages me.

How am I going to resolve this with my nice clear Twitter feed? By using code. I’m going to write a bit of code that downloads and stores all of my tweets – then whenever I do a pruning of my feed I’ll also post a link to where people can find a record of the deleted tweets – that way I still get a nice clean twitter feed, but I remain accountable. (I plan to mainly remove time-relevant tweets rather than conversations – so chatting will stay but observations on last week’s Doctor Who are probably not worth keeping).

It’s six months later, and I am duty bound to admit that the approach failed.  It failed big and in several ways.  It thought it was worth sharing my experience.

First of all I did something slightly different than the above (because I wrote the wrong thing) instead of “no unfollowing of engaged users” I followed every user who replied or retweeted.

This meant I ended up with lots of tweets of the form:

One of the more hideous mistakes I’d made was that I’d presumed that only a small percentage of people on twitter engage actively.  That turned out to be very wrong.  Actually quite a high percentage of people engage, but they all do so fairly irregularly.   So I’m now following 1500 people and I honestly can’t keep up at all. I like to think I can process information with the best of them, but that’s just too much information for it to be in any way fun.  The eventual effect of this was that sooner or later I just gave up, and I’ve barely looked at my timeline (or tweeted) for the last month or so. Which frankly is a waste of a good resource…

The second part of the plan was this:

I also pledge to reply at least once to everyone who messages me.

Which is fine, I got a lot out of it actually – it was nice to chat, to follow up on things. Interestingly, looking at the numbers – being chatty doesn’t make people more likely to message you – they message you when you’ve done something interesting and not because they are just looking for conversation, which I think reflects well on this particular part of the twitter population.

The ‘reply to everyone’ was occasionally a bit of a problem though, because there are some fairly unusual people on the internet.  Occasionally things appeared to call for the reply “Excuse me, are you being racist or did you type the wrong word?”, which isn’t really what I was looking to have to do.

Where this became a problem was this part:

The other problem is that I like to keep a very tidy twitter feed, and generally every few weeks I go back though my tweets and delete anything that isn’t directly informative. This is with the view that someone browsing my feed should find information rather than personality (I get a lot of RT’s from weeks or months ago that appears to support this). The problem with this, is that the engagement I do often vanishes and that’s probably annoying to the other half of the conversation….

[…]

 

  • I also pledge to reply at least once to everyone who messages me.

How am I going to resolve this with my nice clear Twitter feed? By using code. I’m going to write a bit of code that downloads and stores all of my tweets – then whenever I do a pruning of my feed I’ll also post a link to where people can find a record of the deleted tweets – that way I still get a nice clean twitter feed, but I remain accountable. (I plan to mainly remove time-relevent tweets rather than conversations – so chatting will stay but observations on last week’s Doctor Who are probably not worth keeping).

This was a problem because I hadn’t realised that if I’m tweeting ten times as much, it’s actually a lot harder to tidy up the feed. In truth I haven’t had the inclination to do *any* pruning of the feed at all, which has left my feed full of ‘thank you’s and ‘that’s great’s.  And that largely stops it from being a decent resource of interesting things.

A number of people have voted with their feet (fingers) on this.  Before I started, I had 17.1 followers, now I have 16.6.  Most of the loss was in the early stages, which either means that everyone who was going to go went early, or that I’ve annoyed nobody in the last month because I’ve not been tweeting.  (I suspect actually that I normally lose that many people, I’ve just not been attracting replacements because I look like a ‘normal’ rather than ‘useful’ account).

So, in summary – I’m abandoning the experiment.  I’m going back to just promoting good content that I think is useful for people to know – this is what I wrote last time and I think it still stands:

Here’s what I like to think I give back.

  1. Information, specifically regarding disability, technology, and particularly anything involved with both. I have a (genuinely) scientific background and I like to think I’m pretty good at digesting, collecting and rerouting information that is relevant for people in the fields that I care about. I’ve got a number of very personal connections to disability and the major reason that I believe something is relevant to people is that it gets an emotional reaction out of me.

  2. A commitment to try and raise the level of the debate, this means trying to avoid rabble rousing (I’ve been guilty of this in the past) in favour of rational and data-driven content. This doesn’t mean I don’t get angry any more, it means that I try to get angry precisely and that my anger is generally based on peer-reviewed publications… 🙂

So I’m going to start doing various things to bring me back to where I was on Twitter – going to be tightening up my Timeline a little, and doing some pruning of my sources list based much more on informational exchange.  It will be a gradual phasing over. I’m glad I did the experiment – it was worth confirming that I’m information-focused rather than socially-focused.

You are in the minority on Twitter, and so is everyone you listen to.

I was on a bus recently and the two gentlemen in front of me were having a conversation that included the line:

“Look, the thing you’ve got to understand about women from Croydon is-“

(as many of my readers are unlikely to encounter women from Croydon I’ll spare you the alleged insight)

Now, whatever you think about the men, the conversation, and the general state of a world that includes both, we can look at the potential value of the information scientifically.

Croyden includes 364,800 people (thank you Wikipedia) of which we can assume roughly 182,400 are female.

Our man on the bus (OMOTB) is unlikely to know all of them, but he may know a significant fraction. Actually this is where Dunbar’s Number is useful (Dunbar’s Number is roughly defined as the total number of people that a human can maintain a social relationship with, remember birthdays, that sort of thing). Dunbar’s number is normally taken as ‘about 150’. So we can assume that OMOTB knows 75 women reasonably well and if we give him the benefit of the doubt that they all live in Croydon then OMOTB knows roughly 0.04% of all the women in Croydon.

Why am I going on about this? Because the man that says “Look, the thing you’ve got to understand about women from Croydon is-” probably knows much more about women in Croydon than ANYONE WHO TELLS YOU HOW TWITTER WORKS KNOWS ABOUT TWITTER.

Really.

On average 58 million tweets are sent every day. If you read a random sampling of 0.04% of them every day then you probably know as much about twitter culture as OMOTB knows about women (in Croydon).  It would be a bit difficult because that’s 23,848 tweets, which, at an average length of 60 characters (I was surprised but the data is here) means reading more than the length of Harry Potter and the Deathly Hallows every day, just in tweets.

I doubt very much that people writing guides on ‘7 rules for Twitter etiquette’ are managing that much reading.

Conversation between two floating heads:  Head 1: "Twitter is such a great resource", Head 2: "What do you tweet about?", Head 1 "I tweet about how everyone should use tiwtter - it's such a great resource!"

 (Although the people running http://dumbesttweets.com/ probably *are* and that must look a lot like that scene in Clockwork Orange).

Twitter is big. It’s really big. And people don’t understand this. There are hundreds of utterly unrelated subcultures; Teenagers, followers of Band X, fandoms of all types, people looking for support networks, people looking for and finding photos of topless women, people who use Twitter to fight sexism, people who use as an outlet for racism, people who use it only for sports, people who use it only for political activism, robots that obsess over grammar.

Two floating heads saying the same phrase to each other: "Stop using this advocacy platform to promote your clearly insular beliefs!!"

So when you tell me that “It’s polite on twitter to do X” what you mean is “in my tiny sub-bit of twitter we look down on people who don’t do X”.  When you say “Stephen Fry is massive on Twitter, almost everyone follows him” – you mean “Stephen Fry is massive on twitter, because slightly over 1 in 100 Twitter users follows him”.

I understand that people naturally want to feel that they do things ‘properly’  but the thing to take away from this is that however you use Twitter, you are in the minority. There are more people who do things very differently from you than there are who agree with you. Engage with the rest of the world or don’t, but don’t pretend your way is “the way”.

Two floating heads having a conversation. Head 1: "Is that Twitter any good?", Head 2 "Yeah, I'm learning a lot about wimmin from Croydon"

Everything I’ve retweeted (recently)

I think a lot about how I use things like twitter – I want to make sure that I’m providing useful, or at least interesting information to people. I would like to think I’m making the world a tiny bit better not a tiny bit worse.

This post has two objectives:

  • There are a lot of people who sensibly avoid social media because it takes a lot of time. Those people might find it interesting to look at a list of ‘the cool things Joe has found on social media for the last two weeks’.
  • Equally, I’d like to make sure that I am providing value, so it’s worth it for me to review every link (not including stuff to this blog) I’ve retweeted or posted.  It may well be that I think twice about some things in the future. I’d like to be in a position where I was providing a clear narrative.

So let’s begin.  Over the last few weeks I’ve been interested in:

https://twitter.com/FoIManUK/status/444201318077718528

So that’s my catalog of interesting things for the last couple of weeks. It’s better than I expected in that it is relatively focused, broad, and I’ve managed to avoid preachy or political.   If people find the collection of links useful do let me know and I’ll do one of these every so often.  It helps me keep focused and it would be good if it helped other people to.

I’m changing how I use Twitter in 2014

I’m changing how I use Twitter. I’m going to give the details in this post along with the motivation. I started writing this because I believe that if you are going to start acting very differently in any social enviroment (online or off) you should at least give people warning. While writing it I found that it slightly turned into a statement of identity, which is interesting in its own right. Continue reading