Generate QR code cards with Google API
Two-dimensional barcode/Two-D code can be divided into stacked/row-type two-dimensional barcode and matrix two-dimensional barcode. Stacked/row-type two-dimensional barcode form is composed of a multi-line short-cut one-dimensional bar code stacked, matrix-type two-dimensional bar code in the form of a matrix, the corresponding element position in the matrix with "point" for the binary "1", with "empty" means binary "0", "point" and "empty" the arrangement of
Stacked/row-type two-dimensional barcode, such as code 16K, code 49, PDF417, etc.
Matrix-type QR code, the most popular is the code.
Matrix QR Code stores more data, can contain mixed content such as numbers, characters, and Chinese text, and has certain fault tolerance (which can be read normally after partial damage) and high space utilization.
| The code is as follows |
|
<? PHP $vname = ' Test '; $vtel = ' 13800000000 '; Generateqrfromgoogle ($vname, $vtel); function Generateqrfromgoogle ($vname, $vtel, $widhtHeight = ' Max ', $EC _level= ' L ', $margin = ' 0 ') { if ($vname && $vtel) { $chl = "begin:vcardnversion:3.0". vcard Header information "NFN: $vname". "NTEL: $vtel". "Nend:vcard"; vcard Tail Information Echo ' apis.google.com/chart?chs= '. $widhtHeight. ' X '. $widhtHeight. ' &cht=qr&chld= '. $EC _level. ' | '. $margin. ' &chl= '. UrlEncode ($CHL). ' " alt= "QR Code" widhtheight= "'. $size. '" widhtheight= "'. $size. '" /> '; } } ?> |
PHP generated URL qr code:
| The code is as follows |
|
<? PHP $url = "http://www.google.com.hk"; Generateqrfromgoogle ($url); function Generateqrfromgoogle ($chl, $widhtHeight = ' Max ', $EC _level= ' L ', $margin = ' 0 ') { Echo ' apis.google.com/chart?chs= '. $widhtHeight. ' X '. $widhtHeight. ' &cht=qr&chld= '. $EC _level. ' | '. $margin. ' &chl= '. UrlEncode ($CHL). ' " alt= "QR Code" widhtheight= "'. $size. '" widhtheight= "'. $size. '" /> '; } ?> |
Example
| The code is as follows |
|
<?php /* *PHP generates two-dimensional codeCard * API Google * Google API QR code generation "QRCode canStore any text of up to 4,296 alphanumeric types and view the QR code data format " * @param string $chl QR code contains information, which can be numeric, character, binary information, Chinese characters. Data types cannot be mixed, and data must be UTF-8 url-encoded. If you need to pass more than 2K bytes of information, use the Post method * @param int $widhtHeight size setting for two-dimensional code generation * @param string $EC _level Optional error correction level, QR code supports four levels of error correction, used to recover lost, misread, blurred, data. * L-Default: Can identify lost 7% of the data * M-can identify data that has lost 15% * Q can identify data that has lost 25% * H can identify data that has lost 30% * @param int $margin generated QR code away from the pictureThe distance of the border * Two-dimensional codeThe format of the business card---vcard * Format reference is as follows: Begin:vcard version:3.0 FN: User Name TEL; CELL; voice:0571-00000000 TEL; work; voice:0571-00000000 TEL; work; fax:0571-00000000 EMAIL; Pref;internet:361way Url:http://www.111cn.net Org:361way Road of operation and maintenance ROLE: Research and Development Department Title:cto ADR; work; POSTAL: West L. District xxx, Hangzhou, 310000 rev:2014-2-26t08:30:02z End:vcard If you want to customize the format in more detail, you need to know the format standard of the vcard in detail. */ $vcard = Array ( ' VName ' = ' user name ', ' Vtel ' = ' 13800000000 ', ' Vemail ' = ' [email protected] ', ' Vaddress ' and ' Hangzhou city West L. District ', ); Generateqrfromgoogle ($vcard); function Generateqrfromgoogle ($vcard, $widhtHeight = ' Max ', $EC _level= ' L ', $margin = ' 0 ') { if ($vcard) { $chl = "begin:vcardnversion:3.0". vcard Header information "NFN:". $vcard [' VName ']. "NTEL:". $vcard [' Vtel ']. "Nemail:". $vcard [' Vemail ']. "Nadr:". $vcard [' vaddress ']. "Nend:vcard"; vcard Tail Information Echo ' Apis.google.com/chart?chs= '. $widhtHeight. ' X '. $widhtHeight. ' &cht=qr&chld= '. $EC _level. ' | '. $margin. ' &chl= '. UrlEncode ($CHL). ' " alt= "QR Code" widhtheight= "'. $size. '" widhtheight= "'. $size. '" /> '; } } ?> |
If you want to achieve the logo in the middle of the effect, you need to use another logo to join the small image. Only one implementation is available here, or it can be generated in a qrcode way.
Vcode's standard information can be see Wikipedia.
Note: Some of the generated pictures are scanned for data that is caused by encoding, which is more common under Windows, because many editors provide ANSI encoding by default, and changing to UTF8 is OK.
Generate QR code cards with Google API