Skip to content

Instantly share code, notes, and snippets.

@mgng
Created March 16, 2012 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgng/2049207 to your computer and use it in GitHub Desktop.
Save mgng/2049207 to your computer and use it in GitHub Desktop.
DoCoMoのユーザーエージェントからCookie対応/非対応端末を調べる
<?php
$src = file_get_contents( 'http://www.nttdocomo.co.jp/service/developer/make/content/spec/useragent/' );
$src = mb_convert_encoding( $src, 'UTF-8', 'SJIS-win' );
preg_match_all( '/DoCoMo\/[12]\.\d(\s?)[\/a-zA-Z0-9\(\);\+]+/iu', $src, $matches );
if ( ! count( $matches[0] ) ) { exit; }
foreach( $matches[0] as $useragent ) {
$flg = preg_match( '/\ADoCoMo\/2\.0.+c(\d+)/', $useragent, $m ) && (int)$m[1] >= 500 ? '○' : '×';
echo "{$flg} {$useragent}\n";
}
× DoCoMo/2.0 F09B(c100;TJ)
× DoCoMo/2.0 F08C(c100;TB;W20H09)
× DoCoMo/2.0 F08C(c100;TB;W16H09)
× DoCoMo/2.0 F08C(c100;TD)
× DoCoMo/2.0 F08C(c100;TJ)
○ DoCoMo/2.0 P07A3(c500;TB;W24H15)
○ DoCoMo/2.0 P07A3(c500;TB;W42H08)
○ DoCoMo/2.0 P07A3(c500;TB;W20H12)
○ DoCoMo/2.0 P07A3(c500;TB;W35H06)
○ DoCoMo/2.0 P07A3(c500;TB;W30H18)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment