- 2008 : 01 02 03 04 05 06 07 08 09 10 11 12
- 2007 : 01 02 03 04 05 06 07 08 09 10 11 12
- 2006 : 01 02 03 04 05 06 07 08 09 10 11 12
- 2005 : 01 02 03 04 05 06 07 08 09 10 11 12
- 2004 : 01 02 03 04 05 06 07 08 09 10 11 12
- 2003 : 01 02 03 04 05 06 07 08 09 10 11 12
- 2002 : 01 02 03 04 05 06 07 08 09 10 11 12
2006-08-02
Perlでモバイルサイト構築
- Summary
1. User-Agentで端末判別
HTTP::MobileAgentを利用
2. 端末に応じてHTML出力
Template-ToolkitとHTTP::MobileAgentを利用
3. メールアドレスのキャリア判別
Mail::Address::MobileJp
4. 絵文字対応
HTML::Entities::ImodePictogram
3キャリア対応の絵文字削除
- Reference
CodeZine - Perlで作るモバイルサイトのコツ:第1回
http://codezine.jp/a/article.aspx?aid=496
HTTP::MobileAgent
Template-Toolkit
Mail::Address::MobileJp
HTML::Entities::ImodePictogram
1. User-Agentで端末判別
HTTP::MobileAgentを利用
use HTTP::MobileAgent; my $agent = HTTP::MobileAgent->new; if ($agent->is_docomo){ # iモード } elsif ($agent->is_ezweb){ # EZweb } elsif ($agent->is_vodafone){ # Vodafone }
2. 端末に応じてHTML出力
Template-ToolkitとHTTP::MobileAgentを利用
#!/usr/bin/perl use CGI; use Template; use HTTP::MobileAgent; my $q = CGI->new; my $agent = HTTP::MobileAgent->new; my $tt = Template->new({ABSOLUTE => 1}); my $output; # sample.htmlのagentパラメータへ # HTTP::MobileAgentのインスタンスをセットする $tt->process('/path/to/sample.html', {agent => $agent}, \$output) or die $Template::ERROR; print $q->header(-charset=>'Shift_JIS'); print $output; exit;
<html> <body> [% IF agent.is_docomo %] iモード [% ELSIF agent.is_ezweb %] EZweb [% ELSIF agent.is_vodafone %] Vodafone Live! [% ELSE %] Non Mobile... [% END %] </body> </html>
3. メールアドレスのキャリア判別
Mail::Address::MobileJp
use Mail::Address::MobileJp; if (is_imode($email)){ # @docomo.ne.jp }elsif (is_ezweb($email)){ # @ezweb.ne.jp or @*.ezweb.ne.jp }elsif (is_vodafone($email)){ # @jp-*.ne.jp or @*.vodafone.ne.jp # (*にはd,h,t,c,k,r,n,s,qのみが適用となる) }
4. 絵文字対応
HTML::Entities::ImodePictogram
3キャリア対応の絵文字削除
use CGI; use HTML::Entities::ImodePictogram; my $q = CGI->new; my $text = $q->param('text'); # EZwebの絵文字も削除対象にする $HTML::Entities::ImodePictogram::ExtPictorgram_re .= '|[\xF3\xF4\xF6\xF7][\x40-\x7E\x80-\xFC]'; # iモード、EZwebの絵文字を削除 $text = remove_pictogram($text); # Vodafoneの絵文字を削除 $text =~ s/\x1B\$(.+?)\x0F//g;
- Reference
CodeZine - Perlで作るモバイルサイトのコツ:第1回
http://codezine.jp/a/article.aspx?aid=496
HTTP::MobileAgent
Template-Toolkit
Mail::Address::MobileJp
HTML::Entities::ImodePictogram
- 2008 : 01 02 03 04 05 06 07 08 09 10 11 12
- 2007 : 01 02 03 04 05 06 07 08 09 10 11 12
- 2006 : 01 02 03 04 05 06 07 08 09 10 11 12
- 2005 : 01 02 03 04 05 06 07 08 09 10 11 12
- 2004 : 01 02 03 04 05 06 07 08 09 10 11 12
- 2003 : 01 02 03 04 05 06 07 08 09 10 11 12
- 2002 : 01 02 03 04 05 06 07 08 09 10 11 12
2006-08 /