A simple Node-based server that manages likes across arbitrary web pages. Includes JavaScript code for clients that interfaces with the server.
This is the server behind the likes feature on Scripting News.
Full source is provided for the demo app, of course. Please give it a try.
Ask questions. I want to nail this down as quickly as possible, so the sooner you spot problems the sooner they can be addressed.
There's a JavaScript API for the browser. Please review it. Try creating your own app. Follow the example of the demo app. I've tried to make it clear. If you have questions, ask. That'll help me fill out the docs.
There's an even simpler demo app that's just enough to put up a bit of text with a like element adjacent to it. Here's the source.
We use Twitter for identity. We don't read anything from the user's Twitter account, or post anything to it, we use it to know who's doing the liking.
The server uses a SQL database to keep track of likes. Each like consists of three pieces of data, a URL, a screenname and a timestamp. If a user has liked a specific item there's a record in the database. If you unlike it, the record is removed.
The URLs are up to the application. In the demo app, we construct the URL for each item based on the URL of the page followed by # followed by the name of a color.
You are welcome to use my likes server. The client software defaults to using that server, but you can override it.
If you want to run your own server, you have to create an app with Twitter. This used to be open to everyone, but they're making it harder. It's understandable, they have to try to get troll farms under control. But it seems this is a legitimate use of Twitter identity.
It's a way to tell the author that you saw what they wrote and found it likeable. It doesn't mean you necessarily agree. You're also registering your presence to other people who read the blog. It's a way to say hi to the author and others who read the blog. (From a post on Scripting News.)
There are four calls, /toggle, /likes, /mylikes and /toplikes that provide the backend services your app needs.
-
/toggle takes three params, and oauthToken, oauthSecret and the URL of the thing that you are either liking or unliking.
-
/likes takes a URL and returns a list of users who have liked it. It doesn't require oAuth access info.
-
/mylikes takes two params, and oauthToken, oauthSecret and returns an array of URLs the user has liked.
-
/toplikes takes no params, and returns an array of most-liked items, in descending order.
Look in the body of handleHttpRequest in likes.js for all the calls it responds to.
Thejeshgn wrote docs for this API in an innovative way. Comment here.