QR code is being so famous for sharing URLs and Contact ID.There are many webs provide facility for creating QR codes.It’s simple to a generate QR code using Google Chart API.In simple words QR code generator.
: Here We Go :
First you must know how to use GET request and it’s quite simple as well as important.GET request sends a value of a Perameter to the server side script.You just have to write the Parameter name and its value followed by a “=” sing after a question mark(?).
If you want to send “value” on Parameter “para” to the script located at “http://example.com/script” than write this on address bar of a browser
“http://example.com/script?para=value“ (without Quotes)
if you want to enter value of multiple Parameter than place “&” between two Parameter.
.Now we go for real work for QR code Generator.
While we’re using Google Chart API for this we’re just giving some Parameter to a script and the script is returning us a output as a QR code image.
The URL lead to the script is “https://chart.googleapis.com/chart?”
cht=qr -You must add this parameter because this define that you’re asking a QR code from the Google Chart API
chl=<data> – Data of the QR code.It could contain a string or a number.
chs=<width>x<height> – size of the image (in pixels)
This parameters are enough to understand following still you could get more info about the API on http://code.google.com/apis/chart/infographics/docs/qr_codes.html
Write this on your address bar and hit enter ,and you’ll see something.
Let’s make a App using this API:
If you want to create a script that give QR code by writing in a text box this is how to do so.
I’ve thought this very usual algorithm “Replace the constant to a variable “
And this is how it done with PHP :
Take a look at the script,
(notice I’ve named the text area as “txt” you can change it.)
And don’t forget you’re using PHP so you must save it with .php extension.
“<?php echo $GET[‘txt’] ?>” this code writes the value of a field named “txt” so it would write what you write at the text area.This code gives the value of text area to chl parameter.So the image would be containing what you’ve written.It would look like this
IF YOU DON’T HAVE A WEB SERVER WITH PHP THEN THIS CODE WOULD GIVE YOU A BLANK OUTPUT MEANS NOTHING.YOU MUST HAVE A SERVER WITH PHP.
You can get more info about servers on our previous post Get Your Absolute Free WebSite
This is also can be done using JS but i like PHP.If you use JS then you won’t need a special server for it.
Create your own and try it with JS.