top
logo
English (United Kingdom)Italian (Italy)


Errore
  • Errore nel caricamento dei dati feed.
Sample Code

How can I retrieve the values of the capabilities of wurfl ?

Retrieve the values of WURFL capabilities is very simple all the information are defined as the Apache environment AMF_ for example:

from max_image_height the environment name is AMF_MAX_IMAGE_HEIGHT

 

How to read environment in PHP ?

The php code is:

$_SERVER['AMF_MAX_IMAGE_HEIGHT']; 
a test page in php is downloadable at this link. 
demo PHP page is avaiable:http://www.apachemobilefilter.org/test/php_test.php
Here you can download the source: php_test.php.zip

How to read the value in JSP (for Tomcat)?

Before in the httpd.conf file where you have configure mod_jk you must add this:

JkEnvVar AMF_MAX_IMAGE_HEIGHT undefined

The Java code is:

request.getAttribute("AMF_MAX_IMAGE_HEIGHT")

How to read the value in PERL?

print $ENV('AMF_MAX_IMAGE_HEIGHT');

 

 

Simple ?


Here a little example how I build an Mobile Ticket System (demo). Below the code:

index.php

<?php
if ($_SERVER[AMF_XHTML_SUPPORT_LEVEL] != "-1") {
?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Apache Mobile Test</title>
<style type="text/css">

body
{
background-color: #FFFFFF;
font-family: arial, helvetica, sans-serif;
font-size: small;
font-color: #000000
}
</style>
<meta name = "viewport" content = "width = device-width">
</head>
<body>
<center>
<img src="/img/AMFTicket.png" /><br/>
Your Mobile ticket is<br/>
<img src="/cgi-bin/qr.pl" /><br/>
code: AMF
<?php
echo date('h:i:s');
?>
</center>
</body>
</html>
<?php
} else {
header("Content-type: text/vnd.wap.wml");
print "<?xml version=\"1.0\"?>\n";
?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">

<wml>
<card id="card1" title="Apache Mobile Test">
<p>Sorry. Your model is too old</p>
</card>
</wml>
<?php
}
?>

Here the code to generate the QRCode qr.pl:

#!/usr/bin/perl
use GD::Barcode::QRcode;
use Apache2::AMFCommonLib;

binmode(STDOUT);
print "Content-Type: image/png\n\n";
$size=3;
if ($ENV{AMF_MAX_IMAGE_WIDTH} > 160) {
  $size=5;
}
if ($ENV{AMF_MAX_IMAGE_WIDTH} > 220) {
  $size=7;
}
if ($ENV{AMF_MAX_IMAGE_WIDTH} > 240) {
  $size=8;
}
if ($ENV{AMF_MAX_IMAGE_WIDTH} > 280) {
  $size=9;
}
if ($ENV{AMF_MAX_IMAGE_WIDTH} > 330) {
  $size=15;
}
my $CommonLib = new Apache2::AMFCommonLib ();
$data=Date();
print GD::Barcode::QRcode->new("AMF $data", { Ecc => 'L', Version=>2, ModuleSize => $size})->plot->png;
sub Date {
    my $_sec;
        my $_min;
        my $_hour;
        my $_mday;
        my $_day;
        my $_mon;
        my $_year;
        my $_wday;
        my $_yday;
        my $_isdst;
        my $_data;
        ($_sec,$_min,$_hour,$_mday,$_mon,$_year,$_wday,$_yday,$_isdst) = localtime(time);
        $_mon=$_mon+1;
        $_year=substr($_year,1);
        $_mon=&correct_number($_mon);
        $_mday=&correct_number($_mday);
        $_hour=&correct_number($_hour);
        $_min=&correct_number($_min);
        $_sec=&correct_number($_sec);
        $_date="$_hour:$_min:$_sec";
    return $_date;
}
sub correct_number {
  my ($number) = @_;
  if ($number < 10) {
      $number="0$number";
  }
  return $number;
}

 

Commenti (0)
Solo gli utenti registrati possono scrivere commenti!
 

Newsletter





bottom
top

Mobility Site

WMLProgramming

Mobile Monday


bottom

IF sas di Idel Fuschini & C. P.IVA: 09659851001
Powered by Joomla!. Designed by: Free Joomla Themes, hosting. Valid XHTML and CSS.