<?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 "&nbsp;&nbsp;XRD: " . htmlspecialchars($result["xrd"]) . "<br/>";
        printTarget($result["target"]);
    }
}
function printTarget($target)
{
    echo "&nbsp;&nbsp;ID: " . htmlspecialchars($target->id) . "<br/>";
    echo "&nbsp;&nbsp;Name: " . htmlspecialchars($target->name) . "<br/>";
    echo "&nbsp;&nbsp;Prompt: " . $target->prompt . "<br/>";
示例#2
0
        echo "{}";
    } else {
        echo json_encode($target);
    }
    if (isset($callback)) {
        echo ")";
    }
}
if ($cmd == "getUserTargets") {
    header("Content-Type: application/json", true);
    $email = $_REQUEST["email"];
    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") {
示例#3
0
        } else {
            // We have a user, cookie them to remember them
            setcookie('wf_email', $me, time() + 86400 * 14);
        }
    }
    // Do we know of any TO users?
    if (isset($to)) {
        $toEmails = explode(",", $to);
    }
    // If we have just a FROM user, look up their preferred targets.  If we have both to and from, look up all of them
    if (isset($me) && isset($toEmails) && sizeof($toEmails) > 0) {
        $matchTargets = $oex->getCommonUserTargets($me, $toEmails);
        $userTargets = $matchTargets->fromTargets;
    } else {
        if (isset($me)) {
            $userTargets = $oex->getTargetsForUser($me);
        }
    }
    // Ok, we have what we need to render the UI
    require_once "pagestart.inc.php";
    ?>
	<div id="offerpage">
		<?php 
    // If there was a specificaly-entered URL/host, and we found a Target there, prioritize this
    if (isset($explicitTargets) && sizeof($explicitTargets) > 0) {
        // Yes, great
        echo "<h3>Hurrah!</h3>";
        echo "<p>It looks like " . $targetUrl . " can accept your link!  Ready?</p>";
        foreach ($explicitTargets as $target) {
            echo buildTargetLinkForm2($target);
        }