Update library.php to use server authentication
This commit is contained in:
parent
4fdf314736
commit
4dc7b7b286
@ -12,6 +12,8 @@
|
||||
class Monero_Library
|
||||
{
|
||||
protected $url = null, $is_debug = false, $parameters_structure = 'array';
|
||||
private $username;
|
||||
private $password;
|
||||
protected $curl_options = array(
|
||||
CURLOPT_CONNECTTIMEOUT => 8,
|
||||
CURLOPT_TIMEOUT => 8
|
||||
@ -31,12 +33,14 @@ class Monero_Library
|
||||
503 => '503 Service Unavailable'
|
||||
);
|
||||
|
||||
public function __construct($pUrl)
|
||||
public function __construct($pUrl, $pUser, $pPass)
|
||||
{
|
||||
$this->validate(false === extension_loaded('curl'), 'The curl extension must be loaded for using this class!');
|
||||
$this->validate(false === extension_loaded('json'), 'The json extension must be loaded for using this class!');
|
||||
|
||||
$this->url = $pUrl;
|
||||
$this->username = $pUser;
|
||||
$this->password = $pPass;
|
||||
}
|
||||
|
||||
private function getHttpErrorMessage($pErrorNumber)
|
||||
@ -123,6 +127,8 @@ class Monero_Library
|
||||
throw new RuntimeException('Could\'t initialize a cURL session');
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_URL, $this->url);
|
||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $this->username . ":" . $this->password);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $pRequest);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
|
||||
|
Loading…
Reference in New Issue
Block a user