1: <?php
2:
3: namespace webfilesframework\core\datasystem\file\format\media\image;
4:
5:
6: use webfilesframework\core\io\request\MPostHttpRequest;
7:
8: 9: 10: 11: 12: 13:
14: class MQrCodeImage
15: {
16:
17: public $text;
18:
19: public function __construct($text)
20: {
21: $this->text = $text;
22: }
23:
24: public function setText($text)
25: {
26: $this->text = $text;
27: }
28:
29: public function getImageResource()
30: {
31:
32: header("Content-type: image/png");
33:
34: $url = 'https://chart.googleapis.com/chart?chid=' . time();
35: $data = array(
36: 'cht' => 'qr',
37: 'chs' => '300x300',
38: 'chl' => utf8_encode($this->text));
39:
40: $postRequest = new MPostHttpRequest($url, $data);
41: $result = $postRequest->makeRequest();
42:
43:
44: $resource = imagecreatefromstring($result);
45: imagepng($resource);
46: return $resource;
47: }
48:
49: }