add api user agent customization

This commit is contained in:
ghost 2023-09-15 23:24:59 +03:00
parent 11c397b566
commit 034a8c540a
4 changed files with 13 additions and 9 deletions

View file

@ -6,8 +6,8 @@ class Curl
private $_response;
public function __construct(string $url,
array $post = [],
string $userAgent = 'YGGtracker',
array $post = [],
int $connectTimeout = 10,
bool $header = false,
bool $followLocation = false,
@ -17,6 +17,11 @@ class Curl
{
$this->_connection = curl_init($url);
if ($userAgent)
{
curl_setopt($this->_connection, CURLOPT_USERAGENT, $userAgent);
}
if (!empty($post))
{
curl_setopt($this->_connection, CURLOPT_POST, true);
@ -38,11 +43,6 @@ class Curl
curl_setopt($this->_connection, CURLOPT_SSL_VERIFYHOST, $sslVerifyHost);
curl_setopt($this->_connection, CURLOPT_SSL_VERIFYPEER, $sslVerifyPeer);
if ($userAgent)
{
curl_setopt($this->_connection, CURLOPT_USERAGENT, $userAgent);
}
$this->_response = curl_exec($this->_connection);
}