During a recent presentation of Fox Trails, I got some feedback that it might be nice to be able to invoke it from alternative web pages instead of from ASP.Net. Here’s a summary of what would be required to do so, along with a sample php page.

The core functionality of the Default.aspx page is to simply instantiate the Fox Trails component and pass it the web request. Any web development language that can create a COM object can be used to invoke Fox Trails. You may find that you’ll need to add a query string to the first parameter of DispatchRequest if you are not using an ISAPI plugin. The first parameter should be the full url (plus the query string if needed) and the second parameter should be the url path of the page you are using to invoke Fox Trails.

For instance, given the url:
http://localhost/index.php/say/hello/world?sid=12345

You would invoke Fox Trails like this:
$dispatcher->DispatchRequest(”http://localhost/index.php/say/hello/world?sid=12345″, “/index.php”);

Index.php


< ?php

$dispatcher = new COM("demo.Dispatcher");
$dispatcher->AUTOCOMPILE = True;

if ($_SERVER["HTTPS"] == 'off') {
  $proto = 'http://';
} else {
  $proto = 'https://';
}
$host = $_SERVER["HTTP_HOST"];
$url = $_SERVER["PHP_SELF"];
$pathinfo = $_SERVER["PATH_INFO"];
$baseurl = $proto.$host.$url;

$output = array();
foreach($_POST as $key => $item )
{
$output[] = $key . '=' . urlencode($item);
}
foreach($_GET as $key => $item )
{
$output[] = $key . '=' . urlencode($item);
}

if (count($output) > 0) {
  $data = implode('&', $output);
  $querystring = '?' . $data;
} else {
  $querystring = '';
}

echo $dispatcher->DispatchRequest($baseurl.$pathinfo.$querystring, $url);
?>

Leave a Reply

You must be logged in to post a comment.