Creating a proxy to spoof iPhone user-agent in PHP?

后端 未结 3 1394
别跟我提以往
别跟我提以往 2020-12-17 04:52

I\'m writing a web based iPhone simulator and I\'m looking for a way to spoof iPhone\'s Safari browser so that web pages loaded within the simulator (iframe) to use the mobi

3条回答
  •  青春惊慌失措
    2020-12-17 05:24

    If you would like to spoof headers for your end users, then using a User Agent altering browser add-on is not an option. My suggestion is to write a simple PHP script to which you pass the URL to be fetched, and make a PHP cURL request towards that URL, but beforehand you should set the User Agent header with the following call:

    curl_setopt($ch,CURLOPT_HTTPHEADER,array('User-Agent: Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A537a Safari/419.3'));

    I think this should work, but it will kill your server in no time...

提交回复
热议问题