Skip to content
This repository has been archived by the owner on Feb 26, 2018. It is now read-only.

No output given #74

Open
adriaansnoeren opened this issue Aug 21, 2015 · 2 comments
Open

No output given #74

adriaansnoeren opened this issue Aug 21, 2015 · 2 comments

Comments

@adriaansnoeren
Copy link

Just started with the API to provide clients with detailed invoice information. I use the following code:

<?php

require('Moneybird/ApiConnector.php');
spl_autoload_register('Moneybird\ApiConnector::autoload');

$config = array(
    'clientname' => 'clientname', // see Moneybird URL: yourclientname.moneybird.nl
    'emailaddress' => 'emailaddress', // You set this when creating the account
    'password' => 'password', // The password you set in Moneybird when you confirmed the e-mail address
);

// Create a Transport
$transport = new Moneybird\HttpClient();
$transport->setAuth(
    $config['emailaddress'],
    $config['password']
);

$connector = new Moneybird\ApiConnector(
    $config['clientname'],
    $transport, 
    new Moneybird\XmlMapper() // create a mapper
);

$errors = $connector->getErrors();
foreach ($errors as $error) {
    echo $error->attribute . ': ' . $error->message . '<br />';
}

$contactService = $connector->getService('Contact');
$invoiceService = $connector->getService('Invoice');

$contacts = $contactService->getAll();
foreach ($contacts as $contact) {
    echo $contact->name . '<br />';
}

echo 'Requests left: ' . $connector->requestsLeft();

?>

Connecting seems to work. I get the requests left on screen when I remove:

$contacts = $contactService->getAll();
foreach ($contacts as $contact) {
    echo $contact->name . '<br />';
}

Otherwise, nothing gets output. No $errors, nothing. Any ideas? Oh, I use the correct credentials.

@pluijm
Copy link
Member

pluijm commented Aug 21, 2015

No output seems to me you're missing a fatal error which is not displayed on screen. Try again with the next lines after the php opening tag:
ini_set('display_errors', 1);
error_reporting(E_ALL);

@adriaansnoeren
Copy link
Author

Indeed... I configured the error reports in .htaccess but they didn't seem to work. Problem was that no timezone was set in php.ini. Got it working now. Thanks for the fast reply!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants