我正在使用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提供的演示页面:
<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>
我试图给该文件夹写入权限,但这还没有解决它。
答案 0 :(得分:1)
您应该删除持久性目录并重新加载wurfl.xml。听起来它无法完全加载数据库。
答案 1 :(得分:0)
默认情况下,wurfl创建缓存文件夹。移动wurfl的缓存文件夹并再次加载数据库。 我在使用laravel框架时遇到了同样的问题。我移动了缓存并更新了作曲家并解决了问题。它更新了所需的xml文件。