<?

//$docRoot = getenv("DOCUMENT_ROOT");
//require_once $docRoot . "/mobi-config/mobi_lib_constants.php";

// TODO: move to constants file
define('TMP_DIR', '/tmp/'); // cache files that we'll allow the OS to clean out
define('EVENTS_CALENDAR_API', 'http://events.mit.edu/MITEventsFull.wsdl');

MIT_Calendar::init();

// TODO: custom Exception types should be defined somewhere accessible
// to classes that throw them (i.e. in mobi-lib), instead we are
// depending on them to be defined downstream in mobi-web (mobi-sms
// doesn't even define them)
class SoapClientWrapper {
  /* 
    This Wrapper automatically invokes ther generic error handler
    When the Soap Server returns an exception
  */ 
  private $php_client;

  public function __construct($url) {
    $this->php_client = new SoapClient($url);
  }

  public function __call($method, $args) {
    try {
      return call_user_func_array(array($this->php_client, $method), $args);  
    } catch(SoapFault $error) {
      $msg = $error->getMessage();
Exemplo n.º 2
0
class SearchCriterion
{
    private $field;
    private $value;
    public function __construct($field)
    {
        $this->field = $field;
        $args = func_get_args();
        $this->value = array_slice($args, 1);
    }
    public function addValue($value)
    {
        $this->value[] = $value;
    }
    public static function forSOAP(array $criteria)
    {
        $soap_array = array();
        foreach ($criteria as $criterian) {
            $soap_array[] = array("field" => $criterian->field, "value" => $criterian->value);
        }
        return $soap_array;
    }
    public static function fromArray($field, $values)
    {
        $new_obj = new self($field);
        $new_obj->value = $values;
        return $new_obj;
    }
}
MIT_Calendar::init("http://events.mit.edu/MITEventsFull.wsdl");