Location: PHPKode > scripts > Lanyrd API Wrapper in PHP > phuu-lanyrd-php-67808f3/lib/lanyrd.php
<?php
  require_once("CFPropertyList/CFPropertyList.php");

  class Lanyrd {
  
    var $base = "http://lanyrd.com/mobile/ios/";
  
    /* Search & Event Wrapper */
  
    public function search ($query) {
      return $this->get("search/?q=" . urlencode($query)); // Should be htmlentities() / htmlspecialchars()?
    }
  
    public function events ($query) {
      return $this->event_details($query);
    }
  
    public function next_event ($query) {
      $results = $this->events_from_guide($query);
      $event = $this->event_by_id($results[0]["id"]);
      return $event["event"];
    }
  
    public function events_search ($query) {
      $results = $this->search($query);
      return $results["events"];
    }
  
    public function guide ($query) {
      $results = $this->search($query . "&type=guide");
      return $results;
    }
  
    public function events_from_guide ($query) {
      $results = $this->guide($query);
      return $results["events"];
    }
  
    public function event_by_id ($id) {
      return $this->get("event/" . $id);
    }
  
    /* Private */
  
    private function event_details ($query) {
      $results = $this->events_from_guide($query);
      foreach($results as &$event) {
        $event = $this->event_by_id($event["id"]);
      }
      return $results;
    }
  
    private function get ($url) {
      $url = $this->base . $url;
      $results = file_get_contents($url);
      $fp = fopen("./results", "w");
      fwrite($fp, $results);
      fclose($fp);
      return $this->parse("./results");
    }
  
    private function parse ($file) {
      $plist = new CFPropertyList( $file, CFPropertyList::FORMAT_BINARY );
      unlink($file);
      return $plist->toArray();
    }
  
  }
?>
Return current item: Lanyrd API Wrapper in PHP