示例#1
0
文件: index.php 项目: bruno/twfy
                }
            }
            break;
        }
    }
    if (!$match) {
        api_log_call($key);
        api_front_page('Unknown function "' . htmlspecialchars($q_method) . '". Possible functions are: ' . join(', ', array_keys($methods)));
    } else {
        if (get_http_var('docs')) {
            $explorer = ob_get_clean();
            api_documentation_front($method, $explorer);
        }
    }
} else {
    api_front_page();
}
function api_documentation_front($method, $explorer)
{
    global $PAGE, $this_page, $DATA, $methods;
    $this_page = 'api_doc_front';
    $DATA->set_page_metadata($this_page, 'title', "{$method} function");
    $PAGE->page_start();
    $PAGE->stripe_start();
    include_once 'api_' . $method . '.php';
    print '<p align="center"><strong>http://www.openaustralia.org/api/' . $method . '</strong></p>';
    api_call_user_func_or_error('api_' . $method . '_front', null, 'No documentation yet', 'html');
    ?>
<h4>Explorer</h4>
<p>Try out this function without writing any code!</p>
<form method="get" action="?#output">
示例#2
0
/* TODO: move params out of this array and into a fn in the separate API files */
$methods = array('findArticles' => array('parameters' => array('search', 'offset', 'limit'), 'help' => 'Fetch a list of articles matching search criteria'), 'findJournos' => array('parameters' => array('name', 'offset', 'limit'), 'help' => 'Look for journalists'), 'getJourno' => array('parameters' => array('journo'), 'help' => 'Get details about a single journalist'), 'getJournoArticles' => array('parameters' => array('journo', 'offset', 'limit'), 'help' => 'Fetch a list of articles attributed to a journalist'), 'getArticles' => array('parameters' => array('id36', 'url'), 'help' => 'Retrieve information about an article or set of articles'));
$q_method = get_http_var('method');
if (!$q_method) {
    api_front_page();
    return;
}
$match = 0;
foreach ($methods as $method => $data) {
    if (strtolower($q_method) == strtolower($method)) {
        $match = 1;
        break;
    }
}
if (!$match) {
    api_front_page('Unknown function "' . htmlspecialchars($q_method) . '". Possible functions are: ' . join(', ', array_keys($methods)));
    return;
}
include_once 'api_' . $method . '.php';
if (get_http_var('docs')) {
    $_GET['verbose'] = 1;
    ob_start();
}
// collect params (null for missing ones)
$params = array();
foreach ($data['parameters'] as $parameter) {
    $params[$parameter] = get_http_var($parameter, null);
}
if (get_http_var('output') || !get_http_var('docs')) {
    call_user_func('api_' . $method . '_invoke', $params);
}