oconnork00
asked on
Create qr code mailto
Hi all,
I downloaded php qr code from source forge and installed it here Link
What I want is to create a qr code that will do a mailto and also subject and body in an email.
I have seen qr codes that when I scan it the send to fields populated as is the subject and body, but I can't get it to work on that installation.
Any idea how to do this?
Thanks in advance
I downloaded php qr code from source forge and installed it here Link
What I want is to create a qr code that will do a mailto and also subject and body in an email.
I have seen qr codes that when I scan it the send to fields populated as is the subject and body, but I can't get it to work on that installation.
Any idea how to do this?
Thanks in advance
This does not mail QR codes, but it writes them to disk storage on the server. With a little tweak you can email a link to the server-side file. HTH, ~Ray
<?php // RAY_qr_code.php
error_reporting(E_ALL);
// GENERATE QR CODE IMAGES
// SEE http://code.google.com/apis/chart/infographics/docs/qr_codes.html
// SEE http://www.mediapost.com/publications/article/160932/qr-malware-surfaces-on-apps.html
// THE DIRECTORY FOR THE QR CODES
$dir = 'RAY_junk';
$s = "144";
if (!empty($_GET["size"]))
{
$s = strtoupper(trim($_GET["size"]));
switch($s)
{
case "S" : $s = 72; break;
case "M" : $s = 144; break;
case "L" : $s = 288; break;
case "G" : $s = 547; break; // LARGEST FROM TESTS ON 2011-10-20
}
}
$chs = $s . 'x' . $s;
// IF THERE IS DATA
$q = NULL;
if (!empty($_GET["q"]))
{
$q = $_GET["q"];
// MAKE A FILE NAME
$f = $q;
$f = preg_replace('#[^ A-Z0-9/:?&\+\.]#i', NULL, $f);
$f = str_replace(' ', '_', $f);
$f = preg_replace('#[^A-Z0-9]#i', '_', $f);
$f = preg_replace('#_+?#', '_', $f);
// CALL THE QR CODER
$url
= 'https://chart.googleapis.com/chart?'
. 'cht=qr' // CREATE A QR CODE
. '&'
. "chs=$chs" // PIXEL DIMENSIONS (SQUARE)
. '&'
. 'chld=Q' // QUALITY ERROR RECOVERY MEANS UP TO 67 ALPHA-NUMERICS
. '&'
. 'chl=' // THE URLENCODED STRING
. urlencode($q);
;
$qrc = file_get_contents($url);
// WRITE THE IMAGE
$lnk = $dir . DIRECTORY_SEPARATOR . "QR_CODE_$f" . '.png';
file_put_contents($lnk, $qrc);
// CONSTRUCT THE RESPONSE
$txt = htmlentities($q);
$out = <<<OUT
<p>Voila! Here is the QR code for <b>$txt</b></p>
<p><img src="$lnk" title="$f" /></p>
<p>Right-click and save the image, or use this: <a target="_blank" href="$lnk">$f.png</a></p>
<p>Try another?</p>
OUT;
echo $out;
}
$form = <<<FORM
Enter up to 67 characters to see the QR code (maybe a URL?)
<form>
<input type="text" name="q" value="$q" size="67" style="font-family:Courier;" /><br/>
<input type="radio" name="size" value="S" />Small (probably too small)<br/>
<input type="radio" name="size" value="M" />Medium (probably just right)<br/>
<input type="radio" name="size" value="L" />Large<br/>
<input type="radio" name="size" value="G" />Gigantic<br/>
<input type="submit" value="Get QR code" />
</form>
FORM;
echo $form;
ASKER
Danielle,
That works perfectly as I needed, however it seems to work nly for one qr code scanner whilst with another qr scanner it doesn't where as I have seen it working on the same scanner before.
What is it about the scanner that is stopping it working in scanlife qr code scanner?
Ray, is this an alternative to the qr code program? Can it generate a qr code image that I scan and will then trigger the mailto function on my iPhone?
Thanks for all your help
That works perfectly as I needed, however it seems to work nly for one qr code scanner whilst with another qr scanner it doesn't where as I have seen it working on the same scanner before.
What is it about the scanner that is stopping it working in scanlife qr code scanner?
Ray, is this an alternative to the qr code program? Can it generate a qr code image that I scan and will then trigger the mailto function on my iPhone?
Thanks for all your help
It will also depend on the device you are trying to scan on and the settings on that device and the settings in the app. Some apps block e-mails from being created and sent. If you have no default e-mail account set up it can't e-mail. You'd have to check the settings on both the apps and settings on the phone.
ASKER
I see, so I tried doing it with this qr code http://screencast.com/t/HDRhIhcIL and this one works fine in scanlife and the other qr code scanner too, however php qr code that I have been generating the qr code
Why does that qr code work better and how come I can't replicate it? Cheers for the help
Why does that qr code work better and how come I can't replicate it? Cheers for the help
I have used this example script to generate QR codes that I read on my iPhone with QRafter. After scanning the QR code, QRafter gives me a clickable link that goes directly to the online resource(web site). I did not have any email involved - just direct links.
You may need to use a QR code generator that isn't your own. The program you're using may not be able to handle it as well. Try the same mailto: content in something like this:
http://www.qrstuff.com/
Then test it.
http://www.qrstuff.com/
Then test it.
Why does that qr code work better and how come I can't replicate it? - Not sure, but it might have to do with the "version" and the "error correction" levels.
http://code.google.com/apis/chart/infographics/docs/qr_codes.html
http://code.google.com/apis/chart/infographics/docs/qr_codes.html
ASKER
I still can't get this to work using he current qr code generator. So, anyone know of any other open source qr code applications I could try?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks ray
That actually works really well. Is it open source?
That actually works really well. Is it open source?
ASKER
Would still ideally like it to work like this qr code http://screencast.com/t/HDRhIhcIL notice the size of it too, much smaller than the one I just generated. How is that so?
;-)
Sure. I open-sourced it when I posted it here at EE. There are potentially some restrictions on how you can use the data provided by Google, but that is above my pay grade. Please feel free to copy and use my code, and thanks for using Experts Exchange.
All the best, ~Ray
Sure. I open-sourced it when I posted it here at EE. There are potentially some restrictions on how you can use the data provided by Google, but that is above my pay grade. Please feel free to copy and use my code, and thanks for using Experts Exchange.
All the best, ~Ray
ASKER
ThanKs Ray
Just so I know how to use this - I save it in a folder on my server and call the file maybe index.php
Navigate to my folder and then run it from there?
Just so I know how to use this - I save it in a folder on my server and call the file maybe index.php
Navigate to my folder and then run it from there?
That sounds about right. If you're new to PHP, this is an excellent book to help you get off the launch pad.
http://www.sitepoint.com/books/phpmysql4/
http://www.sitepoint.com/books/phpmysql4/
mailto:youremail@mail.com?
Remember to keep it very short because the more information = more complex and unscannable QR Code.