使用php在iframe中加载带有移动模拟器的跨浏览器站点


Load cross-browser site with moblie emulator in iframe using php

我试图在iframe中检查和显示一个跨浏览器的网站,以模拟移动环境。iframe应该以移动格式显示网站。我有一个宽度只有320px的iframe,一些移动网站加载并使用css进行响应式布局,如预期的那样工作。但是对于使用其他技术来检测移动设备的网站不能正确加载。我想把他们都抓起来。我的主要问题是网站的起源,它们不同,不同的url加载在特定的动作上。我没有为此目的开发模拟器,我需要加载这些url来检查它们当前是否完全响应。

我看到了这个网站:

http://php-drops.blogspot.se/2013/07/mobile-emulator-with-php.html

但是不能掌握窍门。我如何在我的框架中加载真正的响应站点?我想当标题告诉环境加载一个不同的网站,如m.site.com。如果有一个独特的移动网站重定向,我怎么能得到那个url?

让它工作,这是我所做的:

        $ch = curl_init();
    curl_setopt($ch, CURLOPT_TIMEOUT,               5);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,        false);
    curl_setopt($ch, CURLOPT_VERBOSE,               true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,        true);
    curl_setopt($ch, CURLOPT_HEADER,                true);
    curl_setopt($ch, CURLOPT_NOBODY,                true);
    curl_setopt($ch, CURLOPT_USERAGENT,             'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3');
    curl_setopt($ch, CURLOPT_URL,                       htmlspecialchars_decode($url));
    curl_setopt($ch, CURLOPT_HTTP_VERSION,      CURL_HTTP_VERSION_1_1);     
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION,        true);
    curl_exec($ch);     
    $info = curl_getinfo($ch);
    curl_close($ch);
    return $info['url'];

我把手机网址拿回来了。因此,如果某些网站转到m.somewebsite或其他网站并在iframe中包含正确的布局:)