Open mundoEarth opened 8 years ago
Please provide some code
hello @pluijm. Here is the code in config.php file :
<?php
error_reporting(E_ALL);
$config = array( 'clientname' => 'https//client.moneybird.nl', 'username' => 'myuser', 'password' => 'password', 'authType' => 'http', 'oauth' => array( 'consumerKey' => '', 'consumerSecret' => '', 'token' => '', 'tokenSecret' => '', ), 'testcontact' => '', );
require_once dirname(FILE) . '/../ApiConnector.php';
spl_autoload_register('Moneybird\ApiConnector::autoload');
Moneybird\ApiConnector::$debug = true;
if (file_exists(dirname(FILE).'/my-config.php')) { include(dirname(FILE).'/my-config.php'); }
if (!function_exists('getTransport')) {
function getTransport($config) {
if ($config['authType'] == 'oauth') {
$transport = new Moneybird\HttpClient\Oauth();
$consumer = new Moneybird\Lib\OAuthConsumer($config['oauth']['consumerKey'], $config['oauth']['consumerSecret'], NULL);
$token = new Moneybird\Lib\OAuthConsumer($config['oauth']['token'], $config['oauth']['tokenSecret']);
$transport->setConsumerAndToken($consumer, $token);
} else {
$transport = new Moneybird\HttpClient();
$transport->setAuth(
$config['username'],
$config['password']
);
}
return $transport;
}
}
//var_dump( getTransport($config) ); $connector = new Moneybird\ApiConnector( $config['clientname'], getTransport($config), new Moneybird\XmlMapper() // create a mapper ); ?>
actually I run this now in localhost.
Client name should be this: 'clientname' => 'client',
@pluijm Thank you its working now.
Hello Sjors. I have an issue with this api, It will display 'Moneybird\InvalidConfigException' with message 'Invalid companyname/clientname'. I am set the $config array correctly but it throws an exception.