How to modify HTTP_USER_AGENT to disguise Web browsers as mobile browsers

Source: Internet
Author: User
Tags user agent switcher
How to modify HTTP_USER_AGENT, disguise the web browser as a mobile browser, and finally edit the post by Youritumei_habataku from 2011-11-am. in PHP, the method for judging whether the browser is a mobile browser is generally: & lt ;? Phpphp determines whether the client is a mobile phone $ agent & nbsp; $ _ SERVER [how to modify HTTP_USER_AGENT and disguise a web browser as a mobile browser

This post was last edited by Youritumei_habataku at 17:10:45, 2011-11-10

In PHP, the following methods are generally used to determine whether the browser is a mobile browser:
// Php determines whether the client is a mobile phone
$ Agent = $ _ SERVER ['http _ USER_AGENT '];
If (strpos ($ agent, "NetFront") | strpos ($ agent, "iPhone") | strpos ($ agent, "MIDP-2.0") | strpos ($ agent, "Opera Mini") | strpos ($ agent, "UCWEB") | strpos ($ agent, "Android") | strpos ($ agent, "Windows CE ") | strpos ($ agent, "SymbianOS "))
Header ("Location: http://bolg.malu.me/photo/wap-mini/index.php ");
?>

If it is a web browser, he will add a code so that he cannot display the page to be displayed, I would like to ask if PHP could modify its $ _ SERVER ['http _ USER_AGENT '] value and disguise itself as an iPhone or other mobile browser, in this way, I can obtain the website's mobile phone webpage content on my computer. the code is as follows:
Ob_start ();
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
// Curl_setopt ($ ch, CURLOPT_POST, 1 );
// Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ param );

// Curl_exec ($ ch );
// $ Retrievedhtml = ob_get_contents ();
$ Retrievedhtml = curl_exec ($ ch );
Ob_end_clean ();
Curl_close ($ ch );

Thank you.
------ Solution --------------------
Use firefox to install the User Agent Switcher extension, which can simulate the ua header access sent by the mobile phone
------ Solution --------------------
Sorry, I have not carefully read the problem.

$ User_agent = my mobile phone '';

Curl_setopt ($ ch, CURLOPT_USERAGENT, $ user_agent );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.