本文整理汇总了PHP中Http::url方法的典型用法代码示例。如果您正苦于以下问题:PHP Http::url方法的具体用法?PHP Http::url怎么用?PHP Http::url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Http
的用法示例。
在下文中一共展示了Http::url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: facebookLogin
/**
* @ignore
*/
public function facebookLogin()
{
Fb::loadApi(true);
Fb::$appRedirectUri = Http::url('home/facebookLogin', true);
Fb::login();
$tUserData = Fb::getUser();
echo 'Welcome ', $tUserData->object['username'], '!';
}
示例2: init
/**
* Register GeoLocation
*
* @param cfg not used
*/
function init($cfg)
{
//! check whether we are enabled
if (empty($cfg['type'])) {
return false;
}
if (Core::$client->ip != "CLI") {
//! AJAX helper to save javascript variables into php session
if (Core::$core->app == "geo" && !empty($_REQUEST['pe_s']) && $_REQUEST['pe_s'] == $_SESSION['pe_s']['geo.action']) {
foreach ($_GET as $k => $v) {
if ($k != "pe_s") {
$_SESSION['pe_geo'][$k] = $v;
}
}
//! mark that we have a high accuracy latitude and longitude values from client
$_SESSION['pe_geoclient'] = 1;
die("OK");
}
//! query location
//! 1-server side (common)
if (function_exists("geoip_record_by_name")) {
if (empty($_SESSION['pe_geo'])) {
$_SESSION['pe_geo'] = geoip_record_by_name(Core::$client->ip);
}
}
//! 2-client side
if ($cfg['type'] == 2) {
View::js("init()", "if(navigator.geolocation)navigator.geolocation.getCurrentPosition(pe_geo,pe_geo);", true);
} elseif ($cfg['type'] == 3) {
View::js("init()", "if(navigator.geolocation)navigator.geolocation.watchPosition(pe_geo,pe_geo);", true);
} elseif ($cfg['type'] == 4 && empty($_SESSION['pe_geoclient'])) {
$ret = @json_decode(Http::get("http://ipinfo.io/" . Core::$client->ip), true);
if (is_array($ret) && !empty($ret['ip'])) {
$r = explode(",", $ret['loc']);
$_SESSION['pe_geo']['postal_code'] = $ret['postal'];
$_SESSION['pe_geo']['country_code'] = $ret['country'];
$_SESSION['pe_geo']['region'] = $ret['region'];
$_SESSION['pe_geo']['city'] = $ret['city'];
$_SESSION['pe_geo']['latitude'] = floatval($r[0]);
$_SESSION['pe_geo']['longitude'] = floatval($r[1]);
$_SESSION['pe_geoclient'] = 1;
}
}
//! both 2 and 3 needs this helper function to make an AJAX call
if ($cfg['type'] == 2 && empty($_SESSION['pe_geoclient']) || $cfg['type'] == 3) {
View::js("pe_geo(p)", "var s='',k,h=new XMLHttpRequest();if(p.code){if(document.body.getAttribute('data-geowarn')==null){document.body.setAttribute('data-geowarn',1);alert('E-GEO: '+L(p.message));}return;}else{document.body.removeAttribute('data-geowarn');for(k in p.coords)if(p.coords.hasOwnProperty(k)){s+='&'+encodeURIComponent(k)+'='+encodeURIComponent(p.coords[k]);}h.open('GET','" . Http::url("geo") . "?pe_s=" . urlencode($_SESSION['pe_s']['geo.action']) . "×tamp='+(p.timestamp?p.timestamp:0)+s,true);h.send(null);}");
}
//! validation
if (!is_array($_SESSION['pe_geo'])) {
$_SESSION['pe_geo'] = [];
}
$_SESSION['pe_geo']['postal_code'] = trim($_SESSION['pe_geo']['postal_code']);
$_SESSION['pe_geo']['country_code'] = trim(strtoupper($_SESSION['pe_geo']['country_code']));
$_SESSION['pe_geo']['region'] = trim($_SESSION['pe_geo']['region']);
$_SESSION['pe_geo']['city'] = trim($_SESSION['pe_geo']['city']);
$_SESSION['pe_geo']['latitude'] = floatval($_SESSION['pe_geo']['latitude']);
$_SESSION['pe_geo']['longitude'] = floatval($_SESSION['pe_geo']['longitude']);
$_SESSION['pe_geo']['altitude'] = floatval($_SESSION['pe_geo']['altitude']);
//! set geo information on client object
Core::$client->geo = $_SESSION['pe_geo'];
}
return true;
}