Blog
2009 posts (16)
Pages:
< Previous 1–10 11–20 Next >
Ordering:
Ascending Descending
11. REST APIs not that RESTful
2009-02-21 16:41:10 by Martynas Jusevičius
I looked at the design of some well-known public APIs for inspiration, especially for RESTful designs.
Last.fm API and Flickr API are pretty neat and quite similar. They offer a set of methods (such as artist.getSimilar to get artists similar to an artist, or photos.getInfo to get information about a photo) and different request methods to call them, such as REST, XML-RPC and SOAP.
However, when I looked into the RESTful method, neither Last.fm REST Requests nor Flickr REST Request Format impressed me because in my eyes the design is not really RESTful. With the aforementioned methods, they go like this:
http://ws.audioscrobbler.com/2.0/?method=artist.getSimilar&api_key=... http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=...
I would have expected something along the lines of:
http://ws.audioscrobbler.com/2.0/music/Fridge/similar http://api.flickr.com/services/rest/photos/2733/&api_key=...
12. OpenID
2009-02-07 13:25:46 by Martynas Jusevičius
Yesterday OpenID Denmark organized an event, which focused on practical and commercial advantages of OpenID support. Main speaker Nat Sakimura presented status, opportunities and roadmap for OpenID, as well as market development and use cases of OpenID in Japan, where it is extremely successful.
Friday also brought a couple exciting news for OpenID. Facebook decided to join OpenID Foundation and is expected to help improving user experience.
The other news come from Lithuania, where all new electronic personal identity cards issued after 1th of January 2009 now have a digital certificate
(x.509) and full OpenID 2.0 and PAPE extension support. National Sertificate Center under the Ministry of Inferior will be the national OpenID provider (at openid.vrm.lt). It is currently in testing mode.
13. Auto-login
2009-01-27 03:25:40 by Martynas Jusevičius
I wanted to implement an auto-login feature on one of the websites, also known as “remember me”. If a user was logged-in the last time he/she was using the website, next time he/she accesses it (in a new browser window) the login should be carried out automatically, without the need to authenticate again. This is common nowadays, found on many login-based Web applications.
Sounds pretty simple, but I looked over the PHP's session and cookie documentation and some examples, and had some second thoughts. Can the implementation be as simple as making the (cookie-based) session persistent, so that it never expires unless the user logs-out? Or maybe expires after some longer time, such as a month, that would probably be safer. This seems to be easily achieved by setting the PHP session cookie lifetime using session_set_cookie_params().
Maybe there are some caveats here? I'm aware of the session fixation exploit, but it seems that a cookie-based solution is one of the safer (not involving HTTPS), and widely-used as well.
14. XML to JSON
2009-01-21 23:14:07 by Martynas Jusevičius
Lately I got involved with some AJAX, namely dynamic maps and autocompletion. It is much more easier to use JSON as the serialization format than XML because no complex parsing is needed, JSON structures automagically become JavaScript objects. So I knew I need my webservice endpoints to return JSON, but the DIY Framework is based on XML serialization of objects.
Luckily, that was no problem at all, since JSON and XML are basically different syntaxes for the same data model, and I knew XML to JSON conversion could be done using an XSLT stylesheet. And of course I found several existing ones:
- json-xslt by Holten Norris / Alan Lewis (used to be hosted at eBay, but the link redirects somewhere else now). XSLT 1.0, not very clean though, all code crammed into one template.
- XSLTJSON by Bram Stein. Seems pretty advanced, supports different JSON syntax conventions, requires XSLT 2.0 however.
- xml2json-xslt by Doeke Zanstra. XSLT 1.0, pretty neat code, uses its own syntax convention. Has several issues: doesn't support XML attributes and arrays of heterogeneous elements.
I wanted support for XSLT 1.0 and XML attributes and arrays, but none of them really did the job. So I decided to fix the issues of xml2json-xslt by adding attribute and array support, and here is the result:
I'm not really sure if it follows any syntax convention, but it does the job for me. Attributes are serialized in the same fashion as elements, this can be switched off using include-attrs parameter (on by default). Children elements with the same name are grouped using Muenchian method and put into arrays.
I've only tested it on relatively simple and flat XML, so bug reports are welcome :)
15. Refresh
2009-01-13 02:16:48 by Martynas Jusevičius
You know you have been programming too long when you paste a file to a folder, and before pressing F5 to refresh Windows Explorer so that all files are sorted nicely again, you think twice if that was a safe request or you might overwrite something as a side effect.
16. Virtual guide mashup
2009-01-07 18:41:14 by Martynas Jusevičius
Some time ago I was asked to put online a simple business card-like website with information about guide services. I came up with the idea to illustrate the real guide service with a virtual guide service, that is, to present notable places of interest on an interactive map. And here is the result: www.guideservice.lt. While it still is in early stages, the technical solution could be interesting to some.
Basically, the website is a mashup based on Google Maps and DBpedia and implemented in JavaScript and SPARQL. Using Lee Feigenbaum's SPARQL client and about 50 lines of JavaScript code, it queries DBpedia's (which is semantically converted Wikipedia) SPARQL endpoint for resources that have geographical coordinates within the bounds of the map, and sets up to a 100 of them as markers on the map. When clicked, the marker opens an info window with title, description, and/or picture of the object. In that way one can virtually explore the area.
This release has several known bugs. Sometimes the request to DBpedia time-outs, and no markers are shown. Another issue is too many markers on the screen which after a while becomes pretty slow.
Does anyone know a way to remove markers that appear out of the map bounds? Currently it is done by simply calling clearOverlays() after the map is moved, but it also closes open info windows.
I think this illustrates well how simple yet powerful DBpedia and SPARQL are. On the other hand, it also proves the need for higher-level semantics. For example, Galle is shown as a place in Lithuania, when in fact it is a crater... on the Moon :)
Pages:
< Previous 1–10 11–20 Next >
Ordering:
Ascending Descending
