【发布时间】:2015-07-12 17:21:21
【问题描述】:
我想使用著名的 Piwik 项目中的php device detector,但我不明白如何在我的 php 代码中包含和使用该代码?我不想使用作曲家。
我写道:
<?php
include 'DeviceDetector.php';
use DeviceDetector\DeviceDetector;
use DeviceDetector\Parser\Device\DeviceParserAbstract;
$dd = new DeviceDetector($_SERVER['HTTP_USER_AGENT']);
$dd->parse();
$clientInfo = $dd->getClient();
var_dump($clientInfo);
但它不起作用。我收到此错误:
Fatal error: Uncaught exception 'Exception' with message 'client parser not found' in D:\DeviceDetector.php:214
Stack trace:
#0 D:\DeviceDetector.php(136): DeviceDetector\DeviceDetector->addClientParser('FeedReader')
#1 D:\index.php(67): DeviceDetector\DeviceDetector->__construct('Mozilla/5.0 (Wi...')
#2 {main}
thrown in D:\DeviceDetector.php on line 214
【问题讨论】:
-
你遇到了什么错误?
-
@KamranAdil 我用错误消息更新问题。
-
我想通了。满容易。获取大师副本并制作一些模组。 pastebin.com/SXBYaC6B
-
感谢@Erick,我可以在您的向导中使用 piwik 设备检测器。您也可以在此处添加 Pastebin 注释作为答案。我现在很高兴:)
-
啊,添加到 DeviceDetector.php - 将它们放在命名空间声明之后。我在这里添加了解决方案作为答案。比较。
标签: php user-agent matomo