QRicketProvider.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace RobThree\Auth\Providers\Qr;
  3. // http://qrickit.com/qrickit_apps/qrickit_api.php
  4. class QRicketProvider extends BaseHTTPQRCodeProvider
  5. {
  6. public $errorcorrectionlevel;
  7. public $margin;
  8. public $qzone;
  9. public $bgcolor;
  10. public $color;
  11. public $format;
  12. function __construct($errorcorrectionlevel = 'L', $bgcolor = 'ffffff', $color = '000000', $format = 'p')
  13. {
  14. $this->verifyssl = false;
  15. $this->errorcorrectionlevel = $errorcorrectionlevel;
  16. $this->bgcolor = $bgcolor;
  17. $this->color = $color;
  18. $this->format = $format;
  19. }
  20. public function getMimeType()
  21. {
  22. switch (strtolower($this->format))
  23. {
  24. case 'p':
  25. return 'image/png';
  26. case 'g':
  27. return 'image/gif';
  28. case 'j':
  29. return 'image/jpeg';
  30. }
  31. throw new \QRException(sprintf('Unknown MIME-type: %s', $this->format));
  32. }
  33. public function getQRCodeImage($qrtext, $size)
  34. {
  35. return $this->getContent($this->getUrl($qrtext, $size));
  36. }
  37. public function getUrl($qrtext, $size)
  38. {
  39. return 'http://qrickit.com/api/qr'
  40. . '?qrsize=' . $size
  41. . '&e=' . strtolower($this->errorcorrectionlevel)
  42. . '&bgdcolor=' . $this->bgcolor
  43. . '&fgdcolor=' . $this->color
  44. . '&t=' . strtolower($this->format)
  45. . '&d=' . rawurlencode($qrtext);
  46. }
  47. }