Twitter: Identifying Potential Followers

In my previous twitter posts (you can see my series of Twitter posts here) I have discussed various things that I have done (or am thinking of doing) to try and get a twitter service up and running, where I tweet on a certain subject for 24 hours, and then I change to something else. That is now all working and seems to be standing up pretty well. You can also subscribe to the service, and I’ll tell you when I start tweeting about your subject(s) of interest. In my last post I was saying that registrations are slow; in fact non-existent.

I mentioned a few ideas about how to attract new followers. One of them was ‘I have been investigating how to collect potential twitter users and then tweet them directly about the service. In fact, the twitter search API provides this type of functionality and I’ll be looking at this soon.‘ Over the past couple of days I have been working on this and I think I have a system that is now just about up and running. It works like this.

I have a cron job (that is a piece of PHP that runs every so often) that tries to identify potential followers. It does this by looking for previous tweets that includes the term that I am currently tweeting about. That might be, for example, ‘Vehicle Routing‘, ‘Healthcare‘ or ‘Bin Packing‘. The twitter API (Applications Programming Interface) actually provides this functionality via its search engine (see here). Once you have received a number of recent tweets that mention your search terms, it’s an easy task to parse that text to be left with just the twitter usernames.

Once I have the usernames, I store them in a database. As well as the usernames, I also store the time I have seen from that person, the number of messages I saw from that person, the last time I tweeted them and the subject that I was tweeting about at the time. When I add a new person to the database, I set their last contact date as four weeks ago (for reasons that will become clear in a moment).

I run this cron job every four hours, so that I do not keep picking up the same messages again and again (and thus incrementing the count of the number of times I have seen the user, when it is, in fact, the same message).

I have had this running for a couple of days now, so now I can start contacting people who might be interested in my twitter feed.

To do this, I have another cron job. At the moment, this runs every thirty minutes, but that is because I am still testing it. It will eventually go to about four hours as I don’t want my twitter feed to get too full of these messages. When I run the job, I extract all the tweets for the current subject and sort it by the number of times I have seen that person. This is on the basis that the more somebody has tweeted about the subject themselves, the more likely that they will be interested in what I to say. I then go through each of these users and check the following:

  1. Do they follow me already? If they do, I ignore them as it is pointless asking somebody to follow you who already is.
  2. Have I tweeted them in the past 30 days? If I have, I ignore them, as I don’t want to annoy people by continually tweeting them. Hopefully, they won’t mind once  a month, but if I do get complaints, I’ll set up an ignore list, so I don’t tweet people on that list.
  3. Have I seen them at least twice? I want to know that they have tweeted at least a couple of times on a given subject. Even so, this is not foolproof. I saw somebody tweet twice about bin packing. They were actually tweeting that they have been packing for their holidays!

If I can find somebody who fulfills the three criteria above, I send them a tweet. Hopefully they will be interested enough to follow me.

So, this is now live. I still need to put in a few things. For example, I need to keep the database tidy, so I need to have some way of deleting records, but that can wait for a while.

It’ll be interesting to see if this actually just annoys people, or does increase my number of followers. I’ll let you know.

 

Tweeting from PHP

For a while I have been looking at ways of tweeting regularly (you can see my series of Twitter posts here). Not to annoy people, but just to have a presence a few times a day. Of course, I hope the tweets are also informative.

A quick google will find many tools that are available to do this but, in my view, they all have their shortcomings. Some want payment,  some you have to have your computer on all the time, some are difficult to use, others only have limited functionality and others did not seem to work at all.

Another problem I found was that there was limited scheduling available. For example, you could send the same tweet every n hours or days. You generally had to pay get anything more sopohisticated.

At one point I was running a number of automatic tweet services, just to try and get the service I wanted but it was not really working and took a long time to maintain.

So what did I actually want?

Nothing fancy. I just wanted to send interesting tweets, at “random” times and be able to configure how many I send each day. I was thinking one every couple of hours; nothing too much.

After some recent sucesses in learning more about PHP and SQL I decided to investigate if there was a better option. A solution where everthing could be hosted on my own domain so that I was in full charge of the system, as did not have to rely on (or logon, or pay for) other services.

After some searching I found a PHP class at http://www.phpclasses.org/. The class in question is called twitter-auto-publish. This provides a simple set of tools that enables you to easily post a tweet, as well as providing other functiality (which I have yet to explore).

To post a tweet is very simple. The following lines of PHP are all that are required (and the presence of the require libraries – but that is just a simple case of copying the files to a relevant folder).

@session_start();

require_once(“../php/twitter-auto-publish/openinviter_base.inc.php”);

require_once(“../php/twitter-auto-publish/twitter_auto_publish.inc.php”);

$user=’your user name’;

$pass=’your password’;

$rochak=new twitter_auto_publish();

$rochak->login($user,$pass);

echo ‘Tweeted: ‘ . $msg; // this is the tweet you wish to publish

$rochak->updateTwitterStatus($msg);

$rochak->logout();

Most of it is quite obvious as to what it does, perhaps not how it does it though! The important thing, as far as I am concerned, is that this gives me the basis on which to tweet. Now I have that, I am able to starting thinking about how to exploit this to develop a system that does what I want it to.

More later.