What are People Tweeting About this Site?


Kynetx Logo

One of the ways that you can use Kynetx rules is to create powerful bookmarklets that modify the current page in some way. In order to demonstrate this, I asked our intern, Jessie Morris, to create a ruleset that displays the last 10 tweets about a Web site. We call this little App "Sweetter."

Sam has already built a feature for generating a bookmarket that is tied to a ruleset into Kynetx AppBuilder, our ruleset building tool. So once you've got a ruleset, creating a bookmarklet is as easy as pushing a button.

To see it in action, just drag this link: Sweetter onto your bookmark toolbar on your browser and then click it. You should see a box appear that looks something like this:

Sweeter screenshot

This works for any site you happen to be on. Just go to the site and click on the bookmark in your toolbar to see what people are saying about that site.

We're making use of Backtweets, a search service that let's you find tweets about, among other things, URLs in the Tweetstream. They have an API that returns JSON, so using them inside the ruleset was as simple as declaring a datasource as follows:

datasource searchBackTweets 
             <- "http://backtweets.com/search.json?key=...&q=" 
                 cachable for 5 minutes;

And then using the datasource to get the data like so:

url = page:env("caller");
domain = url.replace(/http:\\/\\/([A-Za-z0-9.-]+)\\/.*/,"$1");

backTweetsData = datasource:searchBackTweets(domain);
results = backTweetsData.pick("$..totalresults");
tweetImages = backTweetsData.pick("$..tweet_profile_image_url");
tweetUsers = backTweetsData.pick("$..tweet_from_user");
tweetText = backTweetsData.pick("$..tweet_text");

This code gets the domain of the current page, calls the Backtweets datasource with that domain, and then uses the pick operator and JSONPath (think XPath for JSON) to grab relevant data from the results. The rest is just display and is being done with a combination of KRL actions (specifically notify) and some Javascript.

As I mentioned, our intern Jessie--a high school student--built this for me. It took him an hour to get something going that we could see once he found Backtweet and then another day to refine it--most of that was UI work.

Kynetx Apps are deployed using what we call "endpoints" and a bookmarklet is one of the easiest endpoints for users since there's almost nothing to install--just drag a link. Bookmarklet-based Kynetx Apps are great for applications where you want the ruleset to apply across a broad range of Web sites and can--or should--be user activated. Sweetter is a perfect example of that kind of app.

KRL is a great way to build bookmarklet deployed applications because it

  • Provides a nice abstraction for exactly what most people want to do in a bookmarket
  • Overcomes the inherent limitation of bookmarklets (like limitations on length)
  • Allows the bookmarklet to be updated in the cloud without users having to reinstall the bookmarklet

If you're interested in playing with KRL and building Kynetx Apps, you can signup for an account and try it out for free. We'd love to get your feedback.

Note: The API key we're using from Backtweet has a limitation of 1000 calls/day, so if it doesn't give you back results on a site you know has been tweeted, then that's the likely reason. We've asked them to bump up the limit, but haven't heard back from them.


Please leave comments using the Hypothes.is sidebar.

Last modified: Thu Oct 10 12:47:19 2019.