Posts Tagged ‘twitter’

Twitter feed

Went at it again with my cron-powered PHP jobs, this time for putting my Twitter timeline on my homepage. Complete with little bird.

Twitter on the homepage

This is replacing the Friendfeed blog+twitter entries that appeared previously because:

  1. I love playing with new APIs. The T one will be my third personal API integration. Did FF and Flickr prior.
  2. I’ll tweet the better blog entries, so I don’t need a merged blog+twitter feed. Just Twitter is fine.
  3. FF is a second-hand tweet, why not get it first-hand?
  4. FF has great features, but I feel closer to T.  When I had FF on a bunch of different social services it was more worthwhile for the merging of the feed.  But I’ve since whittled it way down.

My PHP cron job is aided by TwitterLibPHP by Justin Poliey.

Tweet a link

Check out my quicky tweeting bookmarklet for Safari and Firefox. Doesn’t shorten URLs yet.

Tossing the Twitter API for my own good

I am changing my approach to Twitter.

Tweet

My former ways

At first it was about playing with the API and studying the response rate to my aggressive follows and link postings.

I wrote a command line tool that helps me find and follow people. A certain number of them would follow back. (I don’t recommend this approach, and I won’t give away my code.)

I would find tweeps based on words specific to my web design industry so I was more likely to find my professional peers. Competitors, in a way, but ultimately a valuable knowledge base and community.

Find unfollowers

My tool then reported on who didn’t reciprocate my follow. It then unfollowed those people.

And did it all again until my API limit ran out. Did it a couple times a day. Really piled up the followers.

About the unfollowing, honestly, people don’t know each other well enough and shouldn’t take it seriously. I followed strangers; I unfollowed strangers who didn’t care about me either. Who cares. If I was a jerk I would be lazy about unfollowing and just unfollow everyone. Then only the reciprocators would be left. But they aren’t suckers. I valued that they followed back. Seriously. So I made sure to return the favor.

My follow bot was aggressive. It followed people who didn’t want to be followed. Every once in a while I would get the DM “who the f&%^ are you?” Fair enough, a#@hole.

False value

After a certain number of followers was achieved, I started to look like I was worth following. This is why people cannot be judged on follower count. There are all kinds of ways to get lots of followers. Mostly misguided. Follower count and value are unrelated. Look at some of these celebs. Turns out they are boring and retarded.

The good thing about suddenly having lots of real people followers is that the likelihood of interesting interaction increases substantially. Most will ignore you. Sorry. They don’t care about your breakfast. They have real jobs.

Accidental friends

Fortunately you’ll accidentally find cool people too that will interact with you like a normal person. Get a few thousand and say something. It’s like yelling in a church. Fun to see who yells back. Because I was doing this at night in California, I tended to connect with lots of waking Australians. I like Australians, especially now.

Spam makes it suck

And one definitely accidentally finds lots of spammers. Before I knew it, Twitter was useless. Too much noise. So many spammers and scammers from who knows where.

“Increase your follower count”, “get rich online”, “whiten your teeth”, “buy acai berries”, and the legions of “social media consultants”. All trash.

Sure, Tweetdeck helped group the valuable people, but I couldn’t group them fast enough. Now there is a iPhone app, but before that it was inconvenient only having the grouping on one of three computers.

My new way

So, as I was saying, I have reversed my approach. Now it’s about finding and unfollowing spammers in an attempt to make Twitter usable. They’ve done so many enhancements to the UI that one hardly needs an app anymore. I kind of want to play with those new built in features.

How I hunt

The first step in the spammer unfollow process is to look for the scammy phrases above. No time for any of them. Unfollow mercilessly.

Then look for anyone pushing products I don’t care about. And anyone otherwise selling their tweets. Magpie. Unfollow.

Then go to the “Following” list and look at people’s “Name”‘s. In my case, I had so many spammers, I could clearly notice duplicate names. Jamessunny, Johngoogle, ToomerJean, Davidpast, WozniakSteve, coodald, Zambrano Carlos, and TorvaldsLinus were popular ones. I got a lot of mileage by blindly unfollowing people.

Then compare the name to the picture. Man name with a female photo? Unfollow.

Then look at the usernames. Apply the spam phrases to the names. Matches? Unfollow.

After staying up late and unfollowing over 400 accounts, which was just scratching the surface, I am now at the point where I am watching my “Home” feed and waiting for anyone else to spam up.

The ones who tweet 10 times all at once are just asking for it. Unfollow.

At this point the tweets start looking like normal people. Now wait for the stupid ones to come out. Unfollow.

When the dust settles, I am sure I am losing followers by changing my policy. These fakes have auto-unfollow enabled in tools such as SocialToo. I know I did. Not anymore.

Clean the stream

I am cleaning the stream. I want to connect now. It’s not about numbers anymore.

Let’s see what it’s worth. And when I say “worth,” I’m not talking money. And those who are talking money… watch out. I am on the hunt.

Twitter is good for something

Good news. I don’t obsess over my 353 feeds anymore.

Bad news.  Now I just skim them to get material for my latest obsession, Twitter.

As of now, 2,398 wonderful people follow me.  Each day I look for more people to follow.  Each day I unfollow unfollowers.

Why are so many people following me?

  1. They want me to follow them.
  2. I contribute often and try to not be annoying.
  3. I follow lots of new people every day.

Read more

The FriendFeed API

First off, let’s define aggregation as taking a bunch of things and putting them all in one place.

Let’s try something.  I’m going to read off a bunch of web services.  Which ones are you a member of?

  • Digg
  • Google Reader
  • Google Talk
  • Gmail
  • Mixx
  • Reddit
  • del.icio.us
  • Furl
  • Ma.gnolia
  • StumbleUpon
  • Jaiku
  • Pownce
  • Twitter
  • Seesmic
  • Vimeo
  • YouTube
  • Flickr
  • Picasa
  • SmugMug
  • Zooomr
  • Tumblr
  • iLike
  • Last.fm
  • Pandora
  • Goodreads
  • LibraryThing
  • Amazon
  • Disqus
  • LinkedIn
  • Netflix Queue
  • Netvibes
  • SlideShare
  • Upcoming
  • Yelp
  • or any blog
  • or anything else putting off an RSS feed

Each of these can be pulled into one feed by FriendFeed.com .

How many of those services are you a member of?  What do you do when you want visitors to see all your posts in one place?  Think about using FriendFeed and harnessing it’s API .  We’ll use it to create a single central feed out of the chaos.

So how does FriendFeed work?  Each member loads up their various accounts from around the web – Google Reader shared articles, Twitter posts, blog entries, YouTube videos, Flickr photos, del.icio.us bookmarks, all that stuff I listed earlier – and members can have discussions around each entry.  It’s a furious stream of information and comments coming from all directions. blogs, news, pictures, etc – all flying by, with comments.  It’s the daily web posting activity of thousands of people in one place.

Facebook already has a nice FriendFeed app so your friends can see your FriendFeed-aggregated posts.

Otherwise showing it on another web page (like a very cool business’ web page) means we’re off to the FriendFeed API.

First thing we need is a FriendFeed account.  They’re free.  Go to friendfeed.com and follow the instructions.

Then load all of your web memberships into FriendFeed so you’ll have stuff in your feed.

Then we need to download the API from http://code.google.com/p/friendfeed-api/ .  Documentation and forums are available at http://friendfeed.com/api/ .

Then, in order to authenticate with the API, we get our new account’s Remote Key from http://friendfeed.com/remotekey .

That’s all the official FriendFeed stuff we need.  Now on to our application.  I called it FriendFeedFormatter.

It is not affiliated with FriendFeed.  Use it all at your own risk. FriendFeed has stated that the API is young and could change at any time.  That disclaimer out of the way…

My code does all the work of taking our nickname and remote key and producing an HTML snippet from our FriendFeed feed that we can then have included in a PHP page.  Download example.zip from the show notes.  It’s got all the code that I’ve written using the API.

http://www.davidvanvickle.com/friendfeed/example.zip

In the show notes is a link to see sample output.  That will give you an idea of what to expect, and you can begin to think of how to embellish it.

http://www.davidvanvickle.com/friendfeed/build.php

There are only two files in example.zip.  One is my FriendFeedFormatter PHP class.  The other is build.php, which is the file you’ll customize and run.

Now find the FriendFeed API you downloaded.  In order for my custom class to work, you’ll need to include the friendfeed.php file from the API in the same folder.

So when you’re done there will be 3 files uploaded to a folder on your PHP enabled web server.  friendfeed.php from the API, plus FriendFeedFormatter.php and build.php.

Before we try to run anything we need to change a couple things inside of build.php.  So open that file in a text editor.

Enter your FriendFeed nickname where it says “MY_NICKNAME”.  Then enter your remote key where it says “MY_REMOTEKEY”.  That’s it.  There are more things we could toggle but let’s start here.

So save and close build.php and upload the 3 files to the web server.  Now you should be able to hit your build.php with a web browser and see what happens.

If all is well then you’ll see the HTML table that the FriendFeedFormatter produced using the API.  Now look in the webserver folder where you uploaded the 3 files.  You should now see a 4th file.  That file is what you’ll be including in your normal web pages.  It is JUST the HTML table displaying your feed.  Just a little piece of a web page, not the whole thing.  Perfect for inserting into a page that already exists.

Why don’t I just write a Javascript snippet like everyone else?  Well because I don’t want to slow my web pages with a call to a remote site.  The FriendFeed servers are pretty fast, but I still don’t want that dependancy if I can help it.  As long as I can run that build.php file on a regular basis, I will have a new enough include file for my site.  And it will load right away.

So how do I run build.php on a regular basis?  Good question.  If you want to automate that, I have half an answer.  If you’re familiar with running cron jobs, or if you want to learn how, cron would be a good way.  Cron allows your server to perform a task – such as calling build.php – according to a schedule, like every few minutes, instead of waiting for a web user to come along and trigger it.  Cron is usually running already.  You don’t have to install it.  Just add a crontab to call lynx, wget, or on older servers, the php cgi executable and pass it build.php and how often it should run.

Truth be told, I don’t have much experience with cron, but it seems to be where people go for scheduling scripts.  I included some examples in the show notes that I scraped from the web to get you started.  I’m sorry that I don’t have more tested examples.

Run every Monday morning at 4:41AM.  (minute hour day month weekday command)

41 04 * * 1 /path/to/lynx http://www.mydomain.com/path/to/your/cron.php
or
41 04 * * 1 /path/to/wget http://www.mydomain.com/path/to/your/cron.php
or
41 04 * * 1 /path/to/php /path/to/your/cron.php

Samples from:
http://www.hackernotcracker.com/2007-04/run-php-scripts-with-crond-and-crontab.html
http://www.modwest.com/help/kb.phtml?cat=2&qid=105

More at
http://www.webmasterworld.com/forum40/1258.htm

Otherwise just keep build.php bookmarked and hit it every time you do something that updates your feed.

Fortunately for server performance, but unfortunate for us, is that FriendFeed is on it’s own schedule.  Just because I update my blog, doesn’t mean FriendFeed is immediately aware of that post.  It may take a few minutes for it to show up in the FriendFeed feed.  (That’s a great reason to figure out how to make the cron way work)

The code to pull in the include file in your PHP page is the same code in build.php that displays the output in the browser.  The FriendFeedFormatter->get_output() method.

Once you see the output, I’m sure you’ll want to customize it more.  Go for it.

I built in a few enhancements.

One enhancement is date formatting.  The date may come to you a couple different ways.  One is in ISO8601 format.  That looks like this. “2008-05-21T15:02:22Z”

Another format would be as a UNIX timestamp, or a long number that represents the number of seconds since January 1, 1970.

You should be able to look in the date column, see which kind of date you have, and change the value of the date format variable in build.php.

$ff_date_format = ‘ ISO8601’; // or ‘unix’

On one server I got one format, on another I got the other format.  I think that’s based on the PHP version I had running but I’m not sure.  Anyway, that’s why my code has two ways to format dates.Another customization is the title of the table.  I recommend making that a link to your Friendfeed page.  The current set up has a link to your FF page, plus a link to  subscribe to your feed.

The formatter has a couple features users may appreciate.  One is inline Youtube videos.  First the user sees a JPG image of the video, but when it is clicked, it turns into a playable video.

Another feature is link detection, which is programmed to happen with Twitter entries.  The static URL’s become clickable.

The last feature is, when Flickr is detected, it lists the thumbnails of the images.

These are things I expected to happen from the API, but they weren’t there, so I added them to my formatter.

Open the formatter and notice how I can treat each service’s entries differently.  I can detect Twitter, for instance, and scan the entry for URL’s to convert into links.  Or I can detect Youtube and make the inline play feature happen.

The important thing is just to hack away to get going using FriendFeed to aggregate your public web activity.

Return top