本文整理汇总了PHP中buildURL函数的典型用法代码示例。如果您正苦于以下问题:PHP buildURL函数的具体用法?PHP buildURL怎么用?PHP buildURL使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了buildURL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
function main()
{
global $ACCESS_TOKEN, $USER_AGENT;
// Set the API sport, method, id, format, and any parameters
$host = 'erikberg.com';
$sport = '';
$method = 'events';
$id = '';
$format = 'json';
$parameters = array('sport' => 'nba', 'date' => '20130414');
// Pass method, format, and parameters to build request url
$url = buildURL($host, $sport, $method, $id, $format, $parameters);
// Set the User Agent, Authorization header and allow gzip
$default_opts = array('http' => array('user_agent' => $USER_AGENT, 'header' => array('Accept-Encoding: gzip', 'Authorization: Bearer ' . $ACCESS_TOKEN)));
stream_context_get_default($default_opts);
$file = 'compress.zlib://' . $url;
$fh = fopen($file, 'rb');
if ($fh && strpos($http_response_header[0], "200 OK") !== false) {
$content = stream_get_contents($fh);
fclose($fh);
printResult($content);
} else {
// handle error, check $http_response_header for HTTP status code, etc.
if ($fh) {
$xmlstats_error = json_decode(stream_get_contents($fh));
printf("Server returned %s error along with this message:\n%s\n", $xmlstats_error->error->code, $xmlstats_error->error->description);
} else {
print "A problem was encountered trying to connect to the server!\n";
print_r(error_get_last());
}
}
}
示例2: idpage_render
function idpage_render($identity)
{
$xrdsurl = buildURL('userXrds') . "?user=" . urlencode($identity);
$headers = array('X-XRDS-Location: ' . $xrdsurl);
$body = sprintf(idpage_pat, buildURL(), $xrdsurl);
return array($headers, $body);
}
示例3: getServer
function getServer()
{
static $server = null;
if (!isset($server)) {
$server =& new Auth_OpenID_Server(getOpenIDStore(), buildURL());
}
return $server;
}
示例4: trust_render
function trust_render($info)
{
$current_user = getLoggedInUser();
$lnk = link_render($current_user);
$trust_root = htmlspecialchars($info->trust_root);
$trust_url = buildURL('trust', true);
$form = sprintf(trust_form_pat, $lnk, $trust_root, $trust_url);
return page_render($form, $current_user, 'Trust This Site');
}
示例5: action_default
/**
* Handle a standard OpenID server request
*/
function action_default()
{
header('X-XRDS-Location: ' . buildURL('idpXrds'));
$server =& getServer();
$method = $_SERVER['REQUEST_METHOD'];
$request = null;
if ($method == 'GET') {
$request = $_GET;
} else {
$request = $_POST;
}
$request = $server->decodeRequest();
if (!$request) {
return about_render();
}
setRequestInfo($request);
if (in_array($request->mode, array('checkid_immediate', 'checkid_setup'))) {
if ($request->idSelect()) {
// Perform IDP-driven identifier selection
if ($request->mode == 'checkid_immediate') {
$response =& $request->answer(false);
} else {
return trust_render($request);
}
} else {
if (!$request->identity && !$request->idSelect()) {
// No identifier used or desired; display a page saying
// so.
return noIdentifier_render();
} else {
if ($request->immediate) {
$response =& $request->answer(false, buildURL());
} else {
/*
if (!getLoggedInUser()) {
return login_render();
}
*/
return trust_render($request);
}
}
}
} else {
$response =& $server->handleRequest($request);
}
$webresponse =& $server->encodeResponse($response);
if ($webresponse->code != AUTH_OPENID_HTTP_OK) {
header(sprintf("HTTP/1.1 %d ", $webresponse->code), true, $webresponse->code);
}
foreach ($webresponse->headers as $k => $v) {
header("{$k}: {$v}");
}
header(header_connection_close);
print $webresponse->body;
exit(0);
}
示例6: about_render
/**
* Render the about page, potentially with an error message
*/
function about_render($error = false, $internal = true)
{
$headers = array();
$body = sprintf(about_body, buildURL());
if ($error) {
$headers[] = $internal ? http_internal_error : http_bad_request;
$body .= sprintf(about_error_template, htmlspecialchars($error));
}
$current_user = getLoggedInUser();
return page_render($body, $current_user, 'OpenID Server Endpoint');
}
示例7: sites_render
function sites_render($sites)
{
if ($sites) {
$rows = siteList_render($sites);
$form = sprintf(sites_form, buildURL('sites'), $rows);
$body = $pre . $form;
} else {
$body = sprintf(sites_empty_message, link_render(buildURL(''), 'Return home'));
}
return page_render($body, getLoggedInUser(), 'Remembered Sites');
}
示例8: trust_render
function trust_render($info)
{
$current_user = getLoggedInUser();
$lnk = link_render(idURL($current_user));
$trust_root = htmlspecialchars($info->trust_root);
$trust_url = buildURL('trust', true);
if ($info->idSelect()) {
$prompt = id_select_pat;
} else {
$prompt = sprintf(normal_pat, $lnk, $trust_root);
}
$form = sprintf(trust_form_pat, $trust_url, $prompt);
return page_render($form, $current_user, 'Trust This Site');
}
示例9: apiCall
function apiCall($apiCall, $site, $filter)
{
global $apiKey;
$url = buildURL($apiCall, $site, $filter, $apiKey);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
if ($result === false) {
$error = curl_error($ch);
curl_close($ch);
throw new Exception("Error calling Stack Exchange API: {$error}");
}
curl_close($ch);
return $result;
}
示例10: login_render
function login_render($errors = null, $input = null, $needed = null)
{
$current_user = getLoggedInUser();
if ($input === null) {
$input = $current_user;
}
if ($needed) {
$errors[] = sprintf(login_needed_pat, link_render($needed));
}
$esc_input = htmlspecialchars($input, ENT_QUOTES);
$login_url = buildURL('login', true);
$body = sprintf(login_form_pat, $login_url, $esc_input);
if ($errors) {
$body = loginError_render($errors) . $body;
}
return page_render($body, $current_user, 'Log In', null, true);
}
示例11: action_show_trust
function action_show_trust()
{
$server =& getServer();
$info = getRequestInfo();
if (!$info) {
$info = $server->decodeRequest();
setRequestInfo($info);
}
$geni_user = geni_loadUser();
$req_url = idURL($geni_user->username);
$trust_root = htmlspecialchars($info->trust_root);
$title = 'GENI OpenID Trust';
$authorize_url = buildURL('authorize', true);
$text = make_trust_page($geni_user, $title, $trust_root, $authorize_url);
$headers = array();
return array($headers, $text);
}
示例12: getAbsoluteStartPage
function getAbsoluteStartPage()
{
global $us;
$urlParts = getCurrentURL();
$parts = parse_url($us->getProperty('badgerStartPage'));
$urlParts['path'] = BADGER_ROOT . '/' . $parts['path'];
if (isset($parts['query'])) {
$urlParts['query'] = $parts['query'];
} else {
unset($urlParts['query']);
}
if (isset($parts['fragment'])) {
$urlParts['fragment'] = $parts['fragment'];
} else {
unset($urlParts['fragment']);
}
return buildURL($urlParts);
}
示例13: navigation_render
function navigation_render($msg, $items)
{
$what = link_render(buildURL(), 'PHP OpenID Server');
if ($msg) {
$what .= ' — ' . $msg;
}
if ($items) {
$s = '<p>' . $what . '</p><ul class="bottom">';
foreach ($items as $action => $text) {
$url = buildURL($action);
$s .= sprintf('<li>%s</li>', link_render($url, $text));
}
$s .= '</ul>';
} else {
$s = '<p class="bottom">' . $what . '</p>';
}
return sprintf('<div class="navigation">%s</div>', $s);
}
示例14: page_render
/**
* Render an HTML page
*/
function page_render($body, $user, $title, $h1 = null, $login = false)
{
$h1 = $h1 ? $h1 : $title;
if ($user) {
$msg = sprintf(logged_in_pat, link_render($user));
$nav = array('logout' => 'Log Out', 'sites' => 'Remembered Sites');
$navigation = navigation_render($msg, $nav);
} else {
if (!$login) {
$msg = link_render(buildURL('login'), 'Log In');
$navigation = navigation_render($msg, array());
} else {
$navigation = '';
}
}
$style = getStyle();
$text = sprintf(page_template, $title, $style, $navigation, $h1, $body);
// No special headers here
$headers = array();
return array($headers, $text);
}
示例15: idpXrds_render
function idpXrds_render()
{
$headers = array('Content-type: application/xrds+xml');
$body = sprintf(idp_xrds_pat, Auth_OpenID_TYPE_2_0_IDP, buildURL());
return array($headers, $body);
}