Exemplo n.º 1
0
// You're probably using a normal browser so expect this to reply with NOTFOUND
echo "<h1>Simple Detection - Using your web browser standard headers (expect NotFound)</h1><p>";
if ($hd->siteDetect()) {
    $tmp = $hd->getReply();
    print_r($tmp);
} else {
    print $hd->getError();
}
echo "</p>";
// This manually sets the headers that a Nokia N95 would set.
// Other agents you also might like to try
// Mozilla/5.0 (BlackBerry; U; BlackBerry 9300; es) AppleWebKit/534.8+ (KHTML, like Gecko) Version/6.0.0.534 Mobile Safari/534.8+
// Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95-3/20.2.011 Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413
// Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5
echo "<h1>Simple Detection - Setting Headers for an N95</h1><p>";
$hd->setDetectVar('user-agent', 'Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95-3/20.2.011 Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413');
$hd->setDetectVar('x-wap-profile', 'http://nds1.nds.nokia.com/uaprof/NN95-1r100.xml');
if ($hd->siteDetect()) {
    $tmp = $hd->getReply();
    print_r($tmp);
} else {
    print $hd->getError();
}
echo "</p>";
// Query for some other information (remember the N95 headers are still set).
// Add detection options to query for additional reply information such as geoip information
// Note : We use the ipaddress to get the geoip location.
echo "<h1>Simple Detection - Passing a different ip address</h1><p>";
$hd->setDetectVar('ipaddress', '64.34.165.180');
if ($hd->siteDetect(array('options' => 'geoip,hd_specs'))) {
    $tmp = $hd->getReply();