Per Søderlind

I code for fun


Facebook ajax rating in php

I’ve written an ajax rating snippet, you’ll find a demo at

It is based on Paul OB’s CSS Star Matrix Pre-loaded

The source code below, should be self explanatory, but if you need input on how to do fbjs ajax, you’ll find documentation and examples over at the facebook development site

[sourcecode language=’php’]
< ?php // the $callbackroot MUST point to your server, if you point it to your, ajax will fail. $callbackroot='http://[PLACE_YOUR_CALLBACK_URL_HERE]'; // do not add a trailing slash e.g.: //AJAX Response (should be first php or in a separate php file): if (isset($_REQUEST['rate'])) { //do something and return "ok" if things are fine echo "ok"; exit; //Important! Stops remaining php after AJAX request is processed }//what ever apicall you use to authenticate, this one is from smiley: $fb = get_fb(); $user = $fb->require_login();

function save_rating(rate) { // array with the class names, used when you add the new class var ratings = [ "nostar", "onestar", "twostar", "threestar", "fourstar", "fivestar" ]; var ajax = new Ajax(); ajax.responseType = Ajax.RAW; ajax.ondone = function(data) { if (data == "ok") { // remove old class names (I don't know which one, so I remove all of them), and add the new document.getElementById('rating_1').removeClassName('nostar').removeClassName('onestar').removeClassName('twostar').removeClassName('threestar').removeClassName('fourstar').removeClassName('fivestar').addClassName(ratings[rate]); } else { new Dialog().showMessage('Dialog', 'set rating failed'); } } ajax.onerror = function() { new Dialog().showMessage('Dialog', 'set rating failed'); }; ajax.requireLogin = 1; var params={"rate":rate };'< ?=$callbackroot?>/rate.php',params); }


A how-to and the rate.css are located at


Internet Direct (Indy for short) is an open source Internet component suite comprised of popular Internet protocols. Indy is the most comprehensive socket library available for any language and contains support for TCP, UDP, ICMP, clients, servers, SMTP, POP3, IMAP4, HTTP, NNTP, FTP, and many more protocols. In fact Indy implements more than 120 protocols and Internet standards!
Indy is available for C#, Visual Basic.Net, Delphi, and Borland C++. Indy is also included in Borland’s Delphi, Kylix, and C++ Builder.

Indy feature matrix as compared to .Net framework

more …

Serving Dynamic Content with HTTP Handlers

Learn how to provide templated URL driven content with HTTP Handlers, using three real-world scenarios presented in this article.

more …

CassiniEx Web Server

Second generation pure .NET web server (written in C#, source available). Based on Cassini Personal Web Server (the one in WebMatrix).

New features:

  • Run multiple web applications in a single instance of CassiniEx
  • CassiniEx loads in system tray
  • Supports multiple host headers and ports per web application
  • Supports multiple virtual folders
  • Each web app has a log file in W3C extended log file format
  • Each web app can allow or deny remote connections
  • Custom default documents per web app

Why CassiniEx? It’s a useful alternative to IIS for developer machines and possibly lightweight Web service endpoints, since it handles nothing but HTTP traffic, thus eliminating a large amount of IIS’ overhead.

more …

Powered by WordPress & Theme by Anders Norén