I was trying to generate QRCode using Google Map API and PHP. When I executed it in a browser it’s giving me a qrcode image. But I implemented same code as an API…It’s just printing image url.
Below is my code
1)This is API:
$app->post('/genQR',function () use($app){
$luname = $app->request->post('luname');
$prof = $app->request->post('prof');
$con = new DbHandler();
$con->genQR($luname,$prof);
});
2)Function part
public function genQR($luname,$prof)
{
$ip = $luname ." ". $prof;
$ex2 = new QRGenerator($ip,150);
header ("content-type:image/png");
echo "<img src=".$ex2->generate().">";
}
When i tested in postman it’s simply giving op in below manner
<img src=https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=pradeep+1&choe=UTF-8&chld=L|4>
What can be the error…??