mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 01:25:39 +00:00
add api user agent customization
This commit is contained in:
parent
11c397b566
commit
034a8c540a
4 changed files with 13 additions and 9 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue