<?PHP

  /**
   * phOSCAR
   * -------
   * An OSCAR-Implementation in PHP 5
   * 
   * This work is distributed within the terms of
   * creative commons attribution-share alike 3.0 germany
   * 
   * See http://creativecommons.org/licenses/by-sa/3.0/ for more information
   * 
   * @author Bernd Holzmueller <bernd@tiggerswelt.net>
   * @revision 03
   * @license http://creativecommons.org/licenses/by-sa/3.0/de/ Creative Commons Attribution-Share Alike 3.0 Germany
   * @homepage http://oss.tiggerswelt.net/oscar/
   * @copyright Copyright &copy; 2009 tiggersWelt.net 
   */

  // Activate some debugging
  error_reporting (E_ALL);
  
  define ("OSCAR_DEBUG_OUT", 1);
  define ("OSCAR_DEBUG_OUT_VERBOSE", 1);
  define ("OSCAR_DEBUG_IN", 1);      
  define ("OSCAR_DEBUG_IN_VERBOSE", 1);
  
  // Load OSCAR
  require ("oscar/client.php");
  
  // Provide a bit abstraction (maybe we'll do this via callbacks, too)
  class Client extends OSCAR_Client {
    public function receiveMessage ($From, $Message) {
      print "Received a message from $From:\n$Message\n\n";
      
      self::sendMessage ($From, "Pong!");
    }
  }
  
  // Create a new Instance from oscar
  $ICQ = new Client;
  
  // Try to login to ICQ network
  if (!$ICQ->login ("ICQ# or AIM Screenname", "Your password")) {
    print "FATAL: Login failed!\n";
    exit (0);
  }
  
  // Main-loop
  while (true) {
    $ICQ->handleEvent ();
    usleep (25);
  }
  
?>