mirror of
https://github.com/RobThree/TwoFactorAuth.git
synced 2026-01-14 03:16:51 +00:00
Since 8.0 a CurlHandle object is returned, and curl_close() has no effect, so this change won't impact earlier versions.
32 lines
810 B
PHP
32 lines
810 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace RobThree\Auth\Providers\Qr;
|
|
|
|
abstract class BaseHTTPQRCodeProvider implements IQRCodeProvider
|
|
{
|
|
protected bool $verifyssl = true;
|
|
|
|
protected function getContent(string $url): string
|
|
{
|
|
$curlhandle = curl_init();
|
|
|
|
curl_setopt_array($curlhandle, array(
|
|
CURLOPT_URL => $url,
|
|
CURLOPT_RETURNTRANSFER => true,
|
|
CURLOPT_CONNECTTIMEOUT => 10,
|
|
CURLOPT_DNS_CACHE_TIMEOUT => 10,
|
|
CURLOPT_TIMEOUT => 10,
|
|
CURLOPT_SSL_VERIFYPEER => $this->verifyssl,
|
|
CURLOPT_USERAGENT => 'TwoFactorAuth',
|
|
));
|
|
$data = curl_exec($curlhandle);
|
|
if ($data === false) {
|
|
throw new QRException(curl_error($curlhandle));
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
}
|