世界武术 | PHP |未加载设备 ID
WURFL | PHP | Device ID not loaded in
我正在使用 WURFL 来检测用户用来连接网站的设备。
这样我就可以将用户重定向到我网站上的移动友好目录,请阅读此处:
Redirect mobile devices to alternate version of my site
我已经下载了 WURFL 和 运行 示例页面。如果我使用桌面加载页面,它工作正常。但是如果我尝试在移动设备上 运行 它 (IOS 8),我会收到以下错误:
Fatal Error: Uncaught exception 'Exception' with message 'There is no device with ID [apple_iphone_ver8] in the loaded WURFL data'
下面是WURFL给出的demo页面:
<html>
<head>
<title>WURFL PHP API Example</title>
</head>
<body>
<?php
// Include the configuration file
include_once './inc/wurfl_config_standard.php';
$wurflInfo = $wurflManager->getWURFLInfo();
if (isset($_GET['ua']) && trim($_GET['ua'])) {
$ua = $_GET['ua'];
$requestingDevice = $wurflManager->getDeviceForUserAgent($_GET['ua']);
} else {
$ua = $_SERVER['HTTP_USER_AGENT'];
// This line detects the visiting device by looking at its HTTP Request ($_SERVER)
$requestingDevice = $wurflManager->getDeviceForHttpRequest($_SERVER);
}
?>
<h3>WURFL XML INFO</h3>
<ul>
<li><h4>VERSION: <?php echo $wurflInfo->version; ?> </h4></li>
</ul>
<div id="content">
User Agent: <b> <?php echo htmlspecialchars($ua); ?> </b>
<ul>
<li>ID: <?php echo $requestingDevice->id; ?> </li>
<li>Brand Name: <?php echo $requestingDevice->getCapability('brand_name'); ?> </li>
<li>Model Name: <?php echo $requestingDevice->getCapability('model_name'); ?> </li>
<li>Marketing Name: <?php echo $requestingDevice->getCapability('marketing_name'); ?> </li>
<li>Preferred Markup: <?php echo $requestingDevice->getCapability('preferred_markup'); ?> </li>
<li>Resolution Width: <?php echo $requestingDevice->getCapability('resolution_width'); ?> </li>
<li>Resolution Height: <?php echo $requestingDevice->getCapability('resolution_height'); ?> </li>
</ul>
<p><b>Query WURFL by providing the user agent:</b></p>
<form method="get" action="index.php">
<div>User Agent: <input type="text" name="ua" size="100" value="<?php echo isset($_GET['ua'])? htmlspecialchars($_GET['ua']): ''; ?>" />
<input type="submit" /></div>
</form>
</div>
</body>
</html>
我试过给文件夹写权限,但是没有解决。
您应该删除持久目录并重新加载wurfl.xml。听起来它无法完全加载数据库。
默认情况下 wurfl 创建缓存文件夹。移动wurfl的缓存文件夹,重新加载数据库。
我在使用 laravel 框架时遇到了同样的问题。我移动了缓存并更新了作曲家,问题得到了解决。它已更新其所需的 xml 文件。
我正在使用 WURFL 来检测用户用来连接网站的设备。 这样我就可以将用户重定向到我网站上的移动友好目录,请阅读此处: Redirect mobile devices to alternate version of my site
我已经下载了 WURFL 和 运行 示例页面。如果我使用桌面加载页面,它工作正常。但是如果我尝试在移动设备上 运行 它 (IOS 8),我会收到以下错误:
Fatal Error: Uncaught exception 'Exception' with message 'There is no device with ID [apple_iphone_ver8] in the loaded WURFL data'
下面是WURFL给出的demo页面:
<html>
<head>
<title>WURFL PHP API Example</title>
</head>
<body>
<?php
// Include the configuration file
include_once './inc/wurfl_config_standard.php';
$wurflInfo = $wurflManager->getWURFLInfo();
if (isset($_GET['ua']) && trim($_GET['ua'])) {
$ua = $_GET['ua'];
$requestingDevice = $wurflManager->getDeviceForUserAgent($_GET['ua']);
} else {
$ua = $_SERVER['HTTP_USER_AGENT'];
// This line detects the visiting device by looking at its HTTP Request ($_SERVER)
$requestingDevice = $wurflManager->getDeviceForHttpRequest($_SERVER);
}
?>
<h3>WURFL XML INFO</h3>
<ul>
<li><h4>VERSION: <?php echo $wurflInfo->version; ?> </h4></li>
</ul>
<div id="content">
User Agent: <b> <?php echo htmlspecialchars($ua); ?> </b>
<ul>
<li>ID: <?php echo $requestingDevice->id; ?> </li>
<li>Brand Name: <?php echo $requestingDevice->getCapability('brand_name'); ?> </li>
<li>Model Name: <?php echo $requestingDevice->getCapability('model_name'); ?> </li>
<li>Marketing Name: <?php echo $requestingDevice->getCapability('marketing_name'); ?> </li>
<li>Preferred Markup: <?php echo $requestingDevice->getCapability('preferred_markup'); ?> </li>
<li>Resolution Width: <?php echo $requestingDevice->getCapability('resolution_width'); ?> </li>
<li>Resolution Height: <?php echo $requestingDevice->getCapability('resolution_height'); ?> </li>
</ul>
<p><b>Query WURFL by providing the user agent:</b></p>
<form method="get" action="index.php">
<div>User Agent: <input type="text" name="ua" size="100" value="<?php echo isset($_GET['ua'])? htmlspecialchars($_GET['ua']): ''; ?>" />
<input type="submit" /></div>
</form>
</div>
</body>
</html>
我试过给文件夹写权限,但是没有解决。
您应该删除持久目录并重新加载wurfl.xml。听起来它无法完全加载数据库。
默认情况下 wurfl 创建缓存文件夹。移动wurfl的缓存文件夹,重新加载数据库。 我在使用 laravel 框架时遇到了同样的问题。我移动了缓存并更新了作曲家,问题得到了解决。它已更新其所需的 xml 文件。