<?php require_once "OExchangeDiscoverer.php"; $oex = new OExchangeDiscoverer(); echo "<h2>getTargetInfoFromXrd</h2>"; $target = $oex->getTargetInfoFromXrd("http://www.oexchange.org/demo/linkeater/oexchange.xrd"); printTarget($target); echo "<h2>getTargetsOnHost</h2>"; $results = $oex->getTargetsOnHost("www.oexchange.org"); printTargetsAndXrdUrls($results); echo "<h2>getTargetsForUser</h2>"; $targets = $oex->getTargetsForUser("*****@*****.**"); printTargets($targets); function printTargets($targets) { foreach ($targets as $target) { printTarget($target); } } function printTargetsAndXrdUrls($results) { foreach ($results as $result) { echo " XRD: " . htmlspecialchars($result["xrd"]) . "<br/>"; printTarget($result["target"]); } } function printTarget($target) { echo " ID: " . htmlspecialchars($target->id) . "<br/>"; echo " Name: " . htmlspecialchars($target->name) . "<br/>"; echo " Prompt: " . $target->prompt . "<br/>";
if (isset($_REQUEST["jsonpcb"])) { $callback = $_REQUEST["jsonpcb"]; } $oex = new OExchangeDiscoverer(); $targets = $oex->getTargetsForUser($email); // Output outputTargetsJson($callback, $targets); } else { if ($cmd == "getHostTargets") { header("Content-Type: application/json", true); $host = $_REQUEST["host"]; if (isset($_REQUEST["jsonpcb"])) { $callback = $_REQUEST["jsonpcb"]; } $oex = new OExchangeDiscoverer(); $results = $oex->getTargetsOnHost($host); // Output outputTargetsAndXrdsJson($callback, $results); } else { if ($cmd == "getTargetDetail") { header("Content-Type: application/json", true); $xrdUrl = $_REQUEST["xrd"]; if (isset($_REQUEST["jsonpcb"])) { $callback = $_REQUEST["jsonpcb"]; } $oex = new OExchangeDiscoverer(); $target = $oex->getTargetInfoFromXrd($xrdUrl); // Output outputTargetJson($callback, $target); } else { if ($cmd == "getCommonUserTargets") {
// Handle the different modes if ($cmd == "share") { $oex = new OExchangeDiscoverer(); // If we have a target URL, get the actual target/targets for that as well if (isset($targetUrl)) { if (strpos($targetUrl, "http") === 0) { // This is a URL, not a hostname $parts = parse_url($targetUrl); if (sizeof($parts["path"]) > 0) { // This looks like a full URL, try to look up an OExchange XRD at this location //echo "Attempting to find an oexchange xrd at " . $targetUrl . "<br/>"; $target = $oex->getTargetInfoFromXrd($targetUrl); } if (!$target) { // Well, this URL wasn't for an XRD, try just the host part of it $results = $oex->getTargetsOnHost($parts["host"]); if (sizeof($results) > 0) { $explicitTargets = array(); for ($i = 0; $i < sizeof($results); $i++) { array_push($explicitTargets, $results[$i]["target"]); } } } else { $explicitTargets = array(); array_push($explicitTargets, $target); } } else { // This might just be a hostname, try that $results = $oex->getTargetsOnHost($targetUrl); if (sizeof($results) > 0) { $explicitTargets = array();