#!/usr/local/bin/php

<?PHP

   function error($n, $m, $f, $l){
     print_r(debug_backtrace());
   }
   
  set_error_handler('error');

  // Include The File
  include("OGoTask.inc");

  // Create The Server Object - hostname, uri, port number
  $server = new OGoServer("kohocton", "/RPC2", 80);

  // Set you user credentials - username, password

  $server->login("adam", "********");

  // Create An XML-RPC Message Object, this one is method name 
  // and has no parameters
  $mesg = $server->xmlrpcmsg("person.getByNumber", 
                             array(new xmlrpcval("SKY27190", "string")));

  // Send the XML-RPC Message To The Server
  $resp = $server->xmlrpcsend($mesg);

  // Check the response, if false the message could not be
  // send or the result was unparsable
  if ($resp == false) {
    // Message Response Invalid Or Response Failed
    die("Ouch! It bit me!");
   } else {
       //  Okay!  Response Contained stuff, lets pull out
       // just the values as the response also contains
       // a bunch of meta-data about the message, server,
       // response, etc...
       $val =  $server->xmlrpcunwrap($resp);
       // If val is an array we got data back, if it is 
       // just a string then that string is an error
       // message
       if (is_array($val)) {
         // Print out the data we got back
         print_r($val);
        } else {
            // val wasn't an array, so something failed
            // we should process the string value of
            // val here into some useful response, but
            // instead we are going to be a smart-a$$
            die("Sorry, I can't read Summarian");
           }
      }
?>
