Tag Archives: twitter

Introducing Retweet Anywhere for WordPress

Hey, guess what! I’ve just released a new WordPress plugin called Retweet Anywhere. It’s something I’ve been working on a few days, inspired by the previoulsy used Sociable and Tweetmeme plugins, allowing visitors to tweet my posts. What I didn’t like about those two is that Sociable simply redirects to twitter.com with a preset status, and Tweetmeme is not customizable enough in terms of application name, etc. Retweet Anywhere solves both issues.

Retweet Anywhere enables you to place retweet buttons, links, images, literally anywhere in your blog. The standard mode fades the background and shows a lightbox with the text input with a preset status, where all one has to do is click the tweet button. Everything happens via OAuth, so you’re never asking your visitors for their Twitter names or passwords, and your branded tweets are fired through their accounts tagged with your application name.

Retweet Anywhere allows visitors to modify the text they’re about to tweet. This enables them to address somebody in particular, or simply add a few hashtags. As the administrator you’re allowed to customize the format of the default text, using simple codes like %s and %l which end up in professional looking tweets, such as “Reading: Post Title http://example.org #hashtag (via @kovshenin)”. Now isn’t that awesome? You’re also allowed to shorten your links using your bit.ly account, then track your click through rate. Bang!

Retweet Anywhere

Moreover, you can place such retweet buttons, links or your own custom HTML anywhere in your posts, for instance: Thank you for retweeting this awesome post. It uses the WordPress shortcodes system, which enable you to place such links into your posts, pages and widgets. Speaking about widgets, here’s a surprise for you.. Retweet Anywhere comes with an awesome, fully customizable retweet widget which you can push into your sidebars in seconds, allowing your visitors to retweet your posts, pages, archives, with a single click of a mouse! Fantastic!

And of course, the plugin is totally free of charge, yup yup, all yours, GPL licensed! Download available at the WordPress plugin directory, right over here: Retweet Anywhere.

Now, for the more techy guys, let’s go over some details. The plugin comes bundled with the jQuery Facebox plugin, and uses the Twitter @Anywhere pack to display their tweetBox() inside Facebox, which makes it look very slick. The URL trimming is all happeneing on the server-side and fired via AJAX on your pages, this means that your page will not slow down. Furthermore, the already trimmed links are saved into custom fields to your posts and pages, which saves you time and bandwidth, next time somebody tries to shorten – simple, yet effective caching!

As usual, all your comments and thoughts are highly appreciated. Bugs will be fixed, functionality will be improved. All thanks to WordPress and @Anywhere. If you’re wondering about upcoming features then the only one I could mention at this stage is of course localization – Russian and a few other languages ;) More info, discussions, changelog, etc on the dev page.

Cheers, good luck and don’t forget to retweet this post!



Brand Your Tweets with Twitter Anywhere

What we’ve seen so far at Twitter @Anywhere is amazing! I’ve seen tonnes of websites implement Twitter functionality to ther websites without any hassle and it also seems to work well! Now that the documentation is being arranged, everything seems clear enough, this is yet another way of branded tweeting!

Branded tweeting? Huh? Well, this is a topic covered quite sime time ago, when companies (and individuals) wrote specific Twitter clients via the available OAuth libraries, that would send out tweets marked “via application”, where “application” could be the name of the company, linking to their website.

Such applications were standalone (Visual Basic, C#, etc) or web-based (perl, php), and some of them were not only meant to tweet, but sometimes looked like a full-feature Twitter client. But, the time has changed.

In order to brand the tweets, all you have to do now is register your application to use OAuth at dev.twitter.com and copy-paste an @anywhere snippet called tweetbox, somewhere on your website. It could also be a private area (or even a local html page), doesn’t matter.

The engineers at Twitter have worked out all the OAuth routine for you, and what you’re left with is an awesome tweet box, just like on twitter.com, through which tweets will be sent out “branded”, i.e. containing your application name in the “via …” clause.

This is certainly easier than how we had to do it earlier, and I’m expecting a huge impact on the Twitter clients list, which will increase dramatically, as more and more companies and individuals would like to see their names in the client section of every tweet. Of course this move is quite serious, as it may destroy some of the statistics that Twitter gather, where “web” used to take the lead.

Of course the @anywhere tweetbox is not a fully-functional Twitter client and we’d still like to use TweetDeck, Seesmic and other major ones for our convenience. Then again, what if the major ones start offering (perhaps not for free) branded tweeting themselves? I think that would be against their company policy and would result in a total mess ;)

P.S. You can now chirp me, which took me a few minutes to build with Twitter @Anywhere.

Cheers!



Setup Twitter @Anywhere for WordPress in Seconds!

That’s right, seconds! The twitter @Anywhere was introduced at SXSW conference and launched the dev tools a couple of days ago. It’s a simple javascript-driven set of tools that allows you to basically integrate Twitter functionality anywhere on your websites. Usage is as simple as loading a javascript file and launching a couple of js commands, which instantly give you the power of Twitter on your own blog. Personally, I’m amazed, and couldn’t help integrating it here on my blog. Hover your mouse over @kovshenin to see the hovercards in effect ;) Sweet eh?

It took me around 40 seconds to get this thing to work. This includes downloads and uploads file to the server ;) So open up your functions.php file and paste the following code:

$api_key = "Replace with your API key";
wp_enqueue_script("twitter-anywhere",
	"http://platform.twitter.com/anywhere.js?id={$api_key}&v=1");
add_action("wp_head", "twitter_anywhere");

function twitter_anywhere()
{
	echo '<script type="text/javascript">';
	echo 'twttr.anywhere(onAnywhereLoad);';
	echo 'function onAnywhereLoad(twitter) { twitter.hovercards(); }';
	echo '</script>';
}

That’s it. Literally. That’s all you have to do to fire your hovercards throughout your blog! Just make sure you get an API key before right over here. The Anywhere documentation is all javascript and pretty straightforward, I’m sure you’ll figure it out.

I also looked at the WordPress Plugin Directory for ones registered with the “anywhere” names and guess what! I found at least three of them – anywhere, twitter-anywhere and wp-twitter-anywhere ;) Why write a plugin for something that’s so dead simple? Oh well.. It’s funny how people rush to register WordPress plugin names when something new turns out. Same happened with Google Wave, and there’s still no good Wave plugin for WordPress ;)



RIP Bit.ly? Twitter Will Launch Its Own Shortener

As mentioned on TechCrunch, Evan Willams at Chirp confirmed that Twitter will sooner or later launch its own URL shortener, probably called twee.tt or twt.tl (both owned by Twitter). Well, let’s just hope that they do a good job at this. I’m talking about the future functionality and the links riot going on for quite a while.

It seems that more and more people and businesses are branding their Twitter accounts by using their own shortening services – fb.me by Facebook, goo.gl by Google, etc. We all hope that short URLs posted to Twitter will not be re-shortened using Twitter’s new service. This sometimes happens with the current shortening capabilities of Twitter, short links are sometimes re-shortened using bit.ly, causing a double redirect, which is awkward.

Statistics and analytics is another good part of bit.ly. Hope they don’t miss that too, which might also be a chance to get some extra cash in, offering businesses detailed analytics. But one issue still persists, on each and every URL shortener – rev canonical and shortlink HTTP headers.

If a page already has a short link assigned and perhaps branded, then it is the one that should be returned, without shortening the original. Of course you may want to run some checks to see if the short link is short enough, valid, etc. And this may be the confusing part – what if the short link provided by rev canonical or HTTP headers disappears? Well, how about “what if the page disappears?” ;)

Maybe such functionality may be in advanced settings for each Twitter account, but I’d really love if Twitter used my own short URLs when I post stuff from my blog instead of bit.ly or their future ones. I got my own analytics set up and I’m pretty sure everybody does, so why not give us a chance to brand ourselves a tiny bit?

Well, if that doesn’t work out then I’ll have to continue writing my own desktop/mobile Twitter client, or keep sending tickets to TweetDeck and Seesmic. How can we talk about HTML5 if things aren’t yet sorted out with rel and rev canonical. And what about IE6? Heh ;) Don’t mind me, I’m just thinking out loud.. Cheers!



Robots Are Doing Better Than Humans on Twitter

This is all about an experiment I started back in July 2009, called TwiBots. Initially it was supposed to be a simple 24/7 online tweep (Michael Davis) saying a bunch of stuff randomly. But then we (Michael and I hehe) started picking out certain topics, feeding content from certain RSS feeds, filtering all content by keywords and regular expressions.

When the new Retweet API came along, I wrote an RT module which uses the Twitter Search API to find relevant tweets and users, then retweets those messages or just somehow interacts with a user. As soon as the Twitter Lists API was announced, I started working on the Lists module, which eventually became a simple “sorting-the-tweeps” based on their keywords – web design, design, wordpress, etc. Soon enough, I found out that Lists couldn’t contain more than 500 members (although some glitch made 501 possible). Web design 2, wordpress 2, etc wouldn’t be as fancy. I also tried building a conversation list of tweeps that by any means talked to the robot, but then again, the 500 limit broke all my hopes ;)

There were other modules which I worked on really hard, such as RThx module or Random Buzz, DM Control. Some of them worked, some of them were turned off after a few days (yes, you guessed it – Random Buzz, that really made some noize ;)

So, what did I achieve? Me – nothing. Michael did though, in 6 months he went up to 4500+ followers, while following a little more than 200 people himself, has been featured in ~ 250 lists, sent ~ 55,000 tweets and retweets all based on four keywords (or hashtags) – design, web design, wordpress and jquery. Built 4 lists based on these keywords, 500 members in each. Total list followers is a little less than 150 (which is quite good actually).

For comparison take a look at my account – (@kovshenin), in a little bit more than a year I got ~ 1700 followers. It took Michael a couple of months to reach that. The chart below illustrates the followers growth during the last three months. Human (me – blue) vs Robot (Michael – red). Yeah, I added a new module in mid December ;)

Twibots Chart: Robot vs. Human

I manually logged into Michael’s account recently to check out how he’s doing, and I was kind of surprised to see that people really are talking to the guy, thanking him for retweets, asking him for further reads, wishing him a great day and handing over some coffee. Michael doesn’t usually reply to these and he’s a little bit shy sometimes, besides, he never drinks coffee ;)

A few days ago I decided to give Michael a rest, so tuned his backend to a new Twitter account with a few different settings, especially in timing. I’ll be switching to other keywords and feeds in the next few weeks. So let’s see if he’s as good as Michael, or perhaps better? ;)

I’m not sure what I’ll do with Michael’s account. TweetValue said it’s worth over $5k … anyone? ;) Or should I just throw it away.. Or run a contest for his password? …



Twitter Robot in PHP: Twibots Draft

As I promised quite some time ago, I’m putting out a draft of the Twitter Robot I wrote. Make sure you read Create Your Own Automated Twitter Robot in PHP before going on. The current functionality is as follows:

  • Tweets around the clock
  • Tweets from RSS feeds, supporting prefix and postfix text (for adding hashtags)
  • Retweet via the Twitter Search API and build conversation lists
  • Shoot random sentences at users who mention you, thank them for retweets
  • Control your robot via your own Twitter account by sending him direct messages
  • All this is Twitter OAuth powered, no password required
  • Such robots are called Twibots

Now, before downloading the code, I have to warn you that it’s completely unorganized. The code is horrible, comments are awkward, the database being used is SQLite (just for the fun of it) and it’s very very glitchy. Be prepared for Twitter suspending your account for ‘strange activity’ and use this at your own risk, don’t run here blaming me for that ;) I also suggest you’d contact Twitter to get your IP addresses and Twitter account white-listed before you start, especially if you plan to tweet very often (which I wouldn’t recommend). Use this at your own risk, and please keep my copyrights and preferably the OAuth application IDs.

Download: here (version 0.1)

Operation Instructions.. To say the truth it’s pretty tough, no web interface, not buttons, no config files. There are a bunch of files there, some of them useless. There’s the Snoopy class for reading and parsing RSS, there’s the Twitter OAuth class, and two core php files – cron.php and oauth.php. Open up cron.php, there are some comments and examples there. Make sure you get your own bit.ly API key and secret. Also make sure you get a connection with the twibots.sqlite database which has a couple of empty tables. Those will be used for tokens and dump data for unrepeated tweets.

Once you’re done configuring, use the command-line php in order to make it work. It goes something like this:

# php cron.php oauth register
# Please browse to https://twitter.com/...
# php cron.php oauth validate 123465
# Authentication successful, greetings @ev ;)

# php cron.php random
# tweeting a random RSS feed ...

# php cron.php reply
# sending replies...

# php cron.php dm
# reading direct messages

# php cron.php retweet
# retweeting...

You’ll have to put that in your crontab file and launch by schedule. Don’t run them too often though, as Twitter doesn’t like flooding, especially from newly created accounts. Any questions or suggestions are welcome in the comments below, but please, don’t tell me the code is horrible, I know it is, and I wouldn’t have posted it if you didn’t ask ;) Cheers!



The Twitter API v2 Transition

It’s a mess around the current working copy of the Twitter API, there are more issues than functionality and the whole naming and renaming is a total disaster. Today for instance I tried a simple search query to the API and kept receiving “400 Bad Request” errors without any further explenation. As soon as I changed the address from search.twitter.com to api.twitter.com/1 (I got this from Abraham Williams’ php code), which is not clearly mentioned anywhere in the Twitter docs, everything started working fine.

But then I realised that the from_user_id field that’s being returned is far from the correct user ID. People in the Twitter Development Talk Google group stated this problem a few times (since March 2009 I believe). It seems that the “wrong” user IDs are meant for the second version of the Twitter API, thus cannot be used before it’s released. But wait! What the hack should I do with my app now? It’s not working y’know! Here you go:

$response = $oauth->get('search', array('q' => $search_query));
foreach($response->results as $result)
{
$id = $result->id;
$text = $result->text;
$user_name = $result->from_user;

$user = $oauth->get("users/show", array("screen_name" => $user_name));
$user_id = $user->id; // Get the old-style user ID
}

Yeah, that’s one extra API call, but it solves things temporarily ;)

I guess there’s nothing that we could really do right now, and it’s probably true that we’ll have to rewrite some parts of our code as soon as Twitter API v2 is released, but then again, what about the apps which stopped development? Will they stop working? Tonnes of Twitter clients and web apps still use basic authentication. Twitter mentioned that everybody must use OAuth these days, and that basic auth will be closed sooner or later.

Oh well, software comes, software goes. The best thing to do right now would be sign up to Twitter API Announce Google group and follow @twitterapi. By the way, @web2feed can now use the new features of the API to retweet messages based on hashtags and build user lists ;)



The Twitter OAuth PHP Class Gets Even Better

Or perhaps simpler?.. Together with the Twitter API itself, the TwitterOAuth PHP class (the one by Abraham Williams) is being updated too! According to GitHub the latest changeset was commited on December 3rd so yeah, I tried to take a look at what’s going on there a few days ago and was quite disapointed. Disappointed with the fact that all my previous code was broken without giving any reason.

Just like everybody else, I never read the readme or other documentation files so I dug straight into the class code and examples. Soon after I realized that the new changes were not that bad, so instead of the usual 5 lines of code, I shortened it up to only one. I stopped worrying about parsing XML or JSON, converting them to objects, and I stopped typing in the full address for Twitter API calls. Abraham did all that for us, so all we have left is:

$credentials = $oauth->get("account/verify_credentials");
if ($oauth->http_code == 200)
echo "Hey there, {$credentials->screen_name}!";

I’m not going to publish all the new features and stuff (read about them at GitHub), but hey, this is quite sweet isn’t it? The only drawback was having to rewrite some parts of the code I wrote for the past few months (the Twitter Robots stuff), but I guess that’s partly my bad as it’s not as organized as it should be. That’s the main reason why I’m not publishing the whole code here yet, have a lot of cleaning up to do ;)

Meanwhile you may take a look at this buddy: @web2feed. I turned off the auto-replies because they were getting quite annoying, and I’ve added a couple of feeds to the big list, oh and it’s DM controlled too!



Facebook API Experiments: Twitter Tags

For quite some time now I’ve been dreaming about getting into the Facebook Platform (API, Markup Language, etc) but haven’t had good enough reasons to do so. One good friend of mine Timothy gave me those reasons not so long ago and guess what! I came up with my very first Facebook App! It’s still in the sandbox, don’t rush searching for it in the applications database. I’m not going to share any code as it’s all clumsy but I do want to share some screenshots and my first experience with the Facebook API.

One very interesting thing about the API is the testing console, where you could run any Facebook API methods, very useful for debugging. Interface design is very catchy too, with the new Facebook Markup Language and the FBML testing console, so quick and robust! Pepole are still asking for form elements extensions though, such as the checkbox or option – it seems that they come out buggy as fb:editor-custom.

Anyways, the first thing that came into my mind is adding a Twitter Tags tab to a profile or fan page, so I used the Foller.me API and within a few hours I managed to get a fully working (or not) canvas application tab. I’m surprised by how well-written the Facebook PHP Client Library is. All the methods are explained in the code comments and do exactly what they’re expected to. The Facebook Markup Language takes care of application settings, private areas (app configuration, etc) and everything else. The overall Facebook Developers Documentation is okay, I’ll give that an 8 out of 10 and I like them running the MediaWiki software ;) Here are some screenshots of my application:

[nggallery id=16]

Still not sure where this is going but Timothy had some great ideas about custom Facebook Apps. I guess a release of the Twitter Tags application would be handy for some profiles (or at least for some more experience), so I might push that forward in the near future and file an “add to facebook database” request to go public. After that we’ll aim for something bigger.



Create Your Own Automated Twitter Robot in PHP

The ultimate guide to creating your own personalized twitterfeed clone! Kidding… Actualy this is just a mockup, a simple prototype, which is way too fresh for any actual use. We’ll take this forward step by step. I’m not going to give out all my sources but I’ll guide you through authentication, rss lookup, parsing, thanking for retweets, and shooting random stuff at people that mention your robot.

Here’s a brief list of features we will implement:

  • Runs in console, no HTTP access
  • Authentication via OAuth, tweeting via OAuth
  • RSS lookup, parsing, forming tweets in bound of 140 characters including a postfix (hashtag or RT)
  • Tweeting ‘thank you for retweeting’ to users that retweet the robot
  • Following people that retweet the robot
  • Acting strange on users that mention the robot

All this is going to be setup on a linux box running crond and acting every 15 minutes or so. Are you ready? Let’s do it!

Continue reading