使用PHP更改用户代理 [英] Change User-Agent Using PHP

查看:139
本文介绍了使用PHP更改用户代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的服务器上有一个应用程序,它会重定向到Facebook,从而显示Facebook登录页面的浏览器版本。

I have an app on my server which redirects to Facebook and thus displays the browser version of the Facebook Login page.

但是,因为我将访问此通过移动设备,我希望它显示Facebook登录页面的移动版本。

However, since I'll be accessing this through a mobile device, I'll want it to display the mobile version of the Facebook login page.

是否可以使用header()函数或是否有在重定向到Facebook之前更改主机上的用户代理的方法?因此,Facebook会认为该请求来自移动设备,因此呈现移动版本。

Is it possible to use the header() function or is there a way to change the user-agent on my host before it redirects to Facebook? So that Facebook will think the request is coming from a mobile device and thus render the mobile version.

我已经尝试使用JavaScript并尝试欺骗header命令;不幸的是这些没有用。

I have already tried to use JavaScript and tried spoofing the header command; unfortunately these didn't work.

谢谢。

推荐答案

ini_set('user_agent', 'MyBrowser v42.0.4711');

这篇关于使用PHP更改用户代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆