I am using QR Generator and using the google API for this. I am generating a QR code which has a URL or we can say link to a website in the QR code. The link is correct when i print it But the problem is that when i pass it to the QR generator, the link is not correct. The correct link is like this. (http://localhost/crs/web/index.php/birthPublicSearch/birthCertificate/view/cert/B/MTc5OQ%3D%3D). But in QR Code The characters after /MTC5OQ does not show in link means that %3D%3D in not shown in QR Image. Can any one help me on this. Below is my code. The other problem is also that when i redirect to the url encoding the image using my cell phone the slashes in the url changes to %2F and the url does not open and a Thank you message is shown for using Neo Reader. How can I solve it.
<?php
class QRGenerator {
protected $size;
protected $data;
protected $encoding;
protected $errorCorrectionLevel;
protected $marginInRows;
protected $debug;
public function __construct($data,$size='100',$encoding='UTF-8',$errorCorrectionLevel='L',$marginInRows=4,$debug=false) {
$this->data=urlencode($data);
$this->size=100;
$this->encoding=($encoding == 'Shift_JIS' || $encoding == 'ISO-8859-1' || $encoding == 'UTF-8') ? $encoding : 'UTF-8';
$this->errorCorrectionLevel=($errorCorrectionLevel == 'L' || $errorCorrectionLevel == 'M' || $errorCorrectionLevel == 'Q' || $errorCorrectionLevel == 'H') ? $errorCorrectionLevel : 'L';
$this->marginInRows=($marginInRows>0 && $marginInRows<10) ? $marginInRows:4;
$this->debug = ($debug==true)? true:false;
}
public function generate(){
$QRLink = "https://chart.googleapis.com/chart?cht=qr&chs=".$this->size."x".$this->size.
"&chl=" . $this->data .
"&choe=" . $this->encoding .
"&chld=" . $this->errorCorrectionLevel . "|" . $this->marginInRows;
if ($this->debug) echo $QRLink;
return $QRLink;} } ?>
And the TD in which i am printing the QR code is as:
<td align="center" valign="top">
<div style="float: left; margin-left: -230px; margin-top: 34px; padding-right: 20px;">
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
});
</script>
</div>
<?php
$unique_value = base64_encode($birhtId);// Unique Value is MTc5OQ
$data='localhost/web/index.php/birthPublicSearch/birthCertificate/view/cert/B/'.$unique_value.'%3D%3D';
$size='200';
$ex1 = new QRGenerator($data,$size);
$img1 = "<img src=".$ex1->generate().">";
$content ='<table>
<tr>
<td colspan="2">'.$img1.'</td>
</tr>
</table>';
print_r($content);
?>
</td>