ASP 替代 User-Agent PHP
我一直在使用 PHP 片段来检测最终用户的用户代理并根据用户代理提供特定于设备的内容。采用的基本逻辑是……“如果您是 iPad,请访问此 URL……如果您是 iPhone,请访问此 URL……如果两者都不是,请继续您的快乐方式并加载随后的 html”。
PHP 代码片段的一切都运行良好。然而,这些文件现在需要从 ASP 服务器提供,我不知道如何在 ASP 中复制该解决方案。所以,我在这里寻求帮助。已经有一位“ASP 专家”在从事这项工作。但是,我们已经进入了没有解决方案的第二周。如果您能提供任何帮助,我们绝对不胜感激。
下面的示例显示了我一直在使用的 PHP。真正的 HTML 由于其长度已被删除。
<?php
//setting the iPhone / iPod / iPad browser variables
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
$ipad = strpos($_SERVER['HTTP_USER_AGENT'],"iPad");
//detecting device browser
if ($iphone == true){
header( 'Location: Webinar_iPhone.mp4' ) ;
}
if ($ipod == true){
header( 'Location: Webinar_iPhone.mp4' ) ;
}
if ($ipad == true){
header( 'Location: Webinar_iPad.mp4' ) ;
}
else {
?>
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
This is a test
</BODY>
</HTML>
<?php
}
?>
谢谢,
谢恩
I've been using a snippet of PHP to detect an end-user's user-agent and deliver device-specific content based on the user-agent. The basic logic employed is...."if you're an iPad, goto this URL...if you're an iPhone, goto this URL...if you're neither, continue on your merry way and load the html that follows".
Everything's been working great with the PHP snippet. However, these files now need to be served from an ASP server and I have no idea how to replicate the solution in ASP. So, I'm asking for help here. There's an 'ASP expert' on the job already. But, we're in our second week of not having a solution. Anything you can do to help is definitely appreciated.
The example below shows the PHP I've been using. The real HTML has been removed because of its length.
<?php
//setting the iPhone / iPod / iPad browser variables
$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
$ipad = strpos($_SERVER['HTTP_USER_AGENT'],"iPad");
//detecting device browser
if ($iphone == true){
header( 'Location: Webinar_iPhone.mp4' ) ;
}
if ($ipod == true){
header( 'Location: Webinar_iPhone.mp4' ) ;
}
if ($ipad == true){
header( 'Location: Webinar_iPad.mp4' ) ;
}
else {
?>
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
This is a test
</BODY>
</HTML>
<?php
}
?>
Thanks,
Shayne
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜你指的是经典 ASP?您可能想查看
Request.ServerVariables("HTTP_USER_AGENT")
我还没有对此进行测试,但为了模拟您想要的内容,您可以执行以下操作:
I assume you mean classic ASP? You would want to look at
Request.ServerVariables("HTTP_USER_AGENT")
I haven't tested this, but to simulate what you want, you'd do something like:
这是我们在主页上用来为移动用户重定向的一个小东西。您可能可以根据您的需要进行调整。
This is a little something we were using on our homepage to redirect for mobile users. You could probably adapt it for your needs.