youngguns-nl / moneybird_php_api

A PHP Library for the MoneyBird API
http://www.moneybird.nl
MIT License
37 stars 14 forks source link

'Moneybird\InvalidConfigException' with message 'Invalid companyname/clientname' #78

Open mundoEarth opened 8 years ago

mundoEarth commented 8 years ago

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.

pluijm commented 8 years ago

Please provide some code

mundoEarth commented 8 years ago

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.

pluijm commented 8 years ago

Client name should be this: 'clientname' => 'client',

mundoEarth commented 8 years ago

@pluijm Thank you its working now.