感谢您查看我的问题。
我想通过使用 file_get_contents() 或 cURL 获取移动版本。我知道这可以通过修改请求中的 HTTP header 来完成。你能给我一个简单的例子吗?
再次感谢!
问候, 桑凯特
最佳答案
作为替代方案,file_get_contents和 stream_context_create也可以使用:
$opts = array('http' =>
array(
'header' => 'User-agent: Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3B48b Safari/419.3',
)
);
$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);
关于php - 如何在 PHP 中使用 file_get_contents() 请求移动版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4936930/