Probleem: Indien MoneybirdApi::$sslInsecure op true staat, werkt niks meer.
Oorzaak: Om de cURL-instellingen voor de $sslInsecure mee te geven, wordt array_merge() gebruikt. Het punt is echter dat alle keys integers zijn en om die reden begint array_merge() vanaf 0 te tellen en worden de oude keys vergeten.
Relevante code: \ Api.php, regel 123 t/m 161.
<?php
/
* Connect with API
* @throws MoneybirdConnectionErrorException
* @access protected
/
protected function initConnection($username, $password)
{
if (!$this->connection = curl_init())
{
throw new MoneybirdConnectionErrorException('Unable to connect to Moneybird Api');
}
else
{
$options = array(
CURLOPT_USERPWD => $username.':'.$password,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/xml',
'Accept: application/xml'
),
);
if (self::$sslInsecure) {
$options = array_merge($options, array(
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
));
}
$setopt = curl_setopt_array($this->connection, $options);
if (!$setopt)
{
throw new MoneybirdConnectionErrorException('Unable to set cURL options'.PHP_EOL.curl_error($this->connection));
}
}
}
?>
Gefixte code
<?php
/*
* Connect with API
* @throws MoneybirdConnectionErrorException
* @access protected
*/
protected function initConnection($username, $password)
{
if (!$this->connection = curl_init())
{
throw new MoneybirdConnectionErrorException('Unable to connect to Moneybird Api');
}
else
{
$options = array(
CURLOPT_USERPWD => $username.':'.$password,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_HTTPHEADER => array(
'Content-Type: application/xml',
'Accept: application/xml'
),
);
if (self::$sslInsecure) {
$options[CURLOPT_SSL_VERIFYHOST] = false;
$options[CURLOPT_SSL_VERIFYPEER] = false;
}
$setopt = curl_setopt_array($this->connection, $options);
if (!$setopt)
{
throw new MoneybirdConnectionErrorException('Unable to set cURL options'.PHP_EOL.curl_error($this->connection));
}
}
}
?>
Probleem: Indien MoneybirdApi::$sslInsecure op true staat, werkt niks meer.
Oorzaak: Om de cURL-instellingen voor de $sslInsecure mee te geven, wordt array_merge() gebruikt. Het punt is echter dat alle keys integers zijn en om die reden begint array_merge() vanaf 0 te tellen en worden de oude keys vergeten.
Relevante code: \ Api.php, regel 123 t/m 161. <?php / * Connect with API * @throws MoneybirdConnectionErrorException * @access protected / protected function initConnection($username, $password) { if (!$this->connection = curl_init()) { throw new MoneybirdConnectionErrorException('Unable to connect to Moneybird Api'); } else { $options = array( CURLOPT_USERPWD => $username.':'.$password, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array( 'Content-Type: application/xml', 'Accept: application/xml' ), );
Gefixte code <?php /* * Connect with API * @throws MoneybirdConnectionErrorException * @access protected */ protected function initConnection($username, $password) { if (!$this->connection = curl_init()) { throw new MoneybirdConnectionErrorException('Unable to connect to Moneybird Api'); } else { $options = array( CURLOPT_USERPWD => $username.':'.$password, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => true, CURLOPT_HTTPHEADER => array( 'Content-Type: application/xml', 'Accept: application/xml' ), );