BaseHTTPQRCodeProvider.php 785 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace RobThree\Auth\Providers\Qr;
  3. abstract class BaseHTTPQRCodeProvider implements IQRCodeProvider
  4. {
  5. /** @var bool */
  6. protected $verifyssl;
  7. /**
  8. * @param string $url
  9. *
  10. * @return string|bool
  11. */
  12. protected function getContent($url)
  13. {
  14. $curlhandle = curl_init();
  15. curl_setopt_array($curlhandle, array(
  16. CURLOPT_URL => $url,
  17. CURLOPT_RETURNTRANSFER => true,
  18. CURLOPT_CONNECTTIMEOUT => 10,
  19. CURLOPT_DNS_CACHE_TIMEOUT => 10,
  20. CURLOPT_TIMEOUT => 10,
  21. CURLOPT_SSL_VERIFYPEER => $this->verifyssl,
  22. CURLOPT_USERAGENT => 'TwoFactorAuth'
  23. ));
  24. $data = curl_exec($curlhandle);
  25. curl_close($curlhandle);
  26. return $data;
  27. }
  28. }