Generation of popular QR codes

Source: Internet
Author: User

Recently more popular QR code, Baidu I found a very good way to use Google interface http://chart.apis.google.com (Gg icon API interface)

Qrcode is a type of QR code. Qrcode can store up to 4296 letters and numbers of any text. These texts can be any content, such as the URL, contact information, and phone number (For details, refer to the QR code data format ). Qr
Information stored by code can be read by optical devices installed with appropriate software. This type of device can be either a dedicated QR code reader or a mobile phone.

Parameter description

Http://chart.apis.google.com/chart? : Call the Google chart API

  1. CHT = QR

    This is required. Tell the API that you need to generate a QR code.
  2. CHS = <width> x
    This is also necessary to inform the API of the size of the QR code you need to generate.
  3. Chlorophyll = <DATA>

    This is required to tell the information contained in the api qr code. It can be numbers, character numbers, characters, binary information, and Chinese characters. The data type cannot be mixed. Data must go through the UTF-8 URL-encoded. If the information to be transmitted exceeds 2 K bytes, use the POST method.
  4. Choe = <output_encoding>

    Finally come a not necessary, this is used to declare the generated QR code contains information encoding, the default is UTF-8; other optional encoding is shift_jis, ISO-8859-1
  5. Chld = <error_correction_level> | <margin>

    Optional Error Correction level. QR codes support four levels of error correction to restore lost, read-wrong, fuzzy, and data. The following are optional values: L-(default) can identify data with 7% loss; m-can identify data with 15% loss; q-can identify data with 25% loss; h-identifies 30% of data loss. Margin refers to the distance between the generated QR code and the image border.

The QR code is square and has the same length and width. The QR code is fixed in size: the length/width from 21 to 177, increasing by 4 pixels each time. Each configuration is called a level. The larger the length and width, the more information is stored. Below is the version summary:

  • The QR code with a level of 1 is 21 pixels in length and width. Up to 25 letters, numbers, and characters can be stored.
  • The QR code with a level of 2 is 25 pixels in length and width. A maximum of 47 letters, numbers, and characters can be stored.
  • ... And so on.

The chart API determines the level of QR code to use based on the size of the information you store. The best QR code reader can read information stored in a QR code of 40. Generally, however, mobile devices can read a maximum of 4 QR codes.

 

The following is a simple test:

Enter the following information in the IE address bar:

Http://chart.apis.google.com/chart? CHT = QR & CHS = 100x100 & chlorophyll = PHP Huaibei

You can get a QR code:

Which of the following is very considerate when PHP is used as the web version? This API supports get and post submission.

About vCard !!! The related introduction is as follows. http://baike.baidu.com/view/495045.htm
<? PHP $ vname = $ _ post ['name']; $ vtel = $ _ post ['tel']; // determines whether the business card information has been submitted, do you want to call the interface to display if ($ vname & $ vtel) {$ chlorophyll = "begin: vCard \ nversion: 3.0 ". // vCard header information "\ nfn: $ vname ". "\ ntel: $ vtel ". "\ nend: vCard"; // vCard tail information echo " "; // urlencode ()}?> <Form method = 'post'> name: <input type = 'text' name = 'name'/> <br/> Tel: <input type = 'text' name = 'tel'/> <br/> <input type = 'submit 'value = 'create QR'> </form>

It should be noted that the file must be UTF-8 encoded, and the declaration of Meta is also utf8, which is an API requirement <metahttp-equiv = "Content-Type" content = "text/html; charset = UTF-8 "/>

See the results:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.