Closed brownbrownbrownbrownbrown closed 11 years ago
Try connecting insecure to rule out any issues with ssl certificates: MoneybirdApi::$sslInsecure = true;
Thanks for the quick reply. I saw this suggestion in another issue, so I tried it, but unfortunately this didn't work.
Strange thing is, I can retrieve the contact info, but cannot update it. I can not retrieve an invoice by id.
Try this patch:
--- Api.php 2012-12-08 10:31:27.699404568 +0100
+++ Api_new.php 2012-12-08 10:31:27.835404571 +0100
@@ -62,6 +62,9 @@
* @var bool
*/
static public $sslInsecure = false;
+
+ protected $username;
+ protected $password;
/**
* Constructor
@@ -77,8 +80,8 @@
{
// Set defaults
$this->clientname = $clientname != null ? $clientname : 'clientname';
- $username = $username != null ? $username : 'username';
- $password = $password != null ? $password : 'password';
+ $this->username = $username != null ? $username : 'username';
+ $this->password = $password != null ? $password : 'password';
if (preg_match('/^[a-z0-9_\-]+$/', $this->clientname) == 0)
{
@@ -89,7 +92,7 @@
$this->errors = array();
$this->lastRequest = null;
- $this->initConnection($username, $password);
+ $this->initConnection();
}
/**
@@ -131,7 +134,7 @@
* @throws MoneybirdConnectionErrorException
* @access protected
*/
- protected function initConnection($username, $password)
+ protected function initConnection()
{
if (!$this->connection = curl_init())
{
@@ -140,7 +143,7 @@
else
{
$options = array(
- CURLOPT_USERPWD => $username.':'.$password,
+ CURLOPT_USERPWD => $this->username.':'.$this->password,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYHOST => true,
@@ -185,6 +188,7 @@
*/
protected function request($url, $method='GET', iMoneybirdObject $mbObject=null, iMoneybirdObject $parent=null)
{
+ $this->initConnection();
$url = '/'.$url;
// If called from a contact, add contacts/:id
This works. Thanks a lot!
I'm having a problem with writing data to moneybird, since probably December 3. The error occures when I try to retrieve a contact.
$mbapi = new MoneybirdApi('credential1', 'credential2', 'credential3'); $contact = $mbapi->getContact($contactId); $contact->company_name = 'Test naam als test'; try { $contact->save(); } catch (exception $e) { $validationErrors = $e->getMessage();
}
MoneybirdUnknownResponseException [ 0 ]: Unknown response from Moneybird: 0
From Moneybird I understood that some IP's are changed. I'm using the previous version of the API, since the wehost is still php 5.2, so upgrading is not an option.
Any ideas on how this is possible?
Thanks in advance!