Update contact using Light PHP wrapper

I’m having problems creating a new contact in FreeAgent.

I’m using the Light PHP wrapper for the OAuth 2.0 protocol and have managed to successfully set up oAuth2. I can connect to FreeAgent and successfully retrieve a list of customers. So far, so good. The problem I’ve got is sending data back the other way, i.e. creating a new contact in FreeAgent.

Here’s some code I’ve tried:


$client = new OAuth2\Client($clientid, $secret);

$params = json_encode(array('contact' => array('first-name' => $firstname_unencrypted, 'last-name' => $surname_unencrypted)));
$response = $client->fetch("/contacts", $params, "POST", array('User-Agent' => 'MyApp', 'Accept' => 'application/json', 'Content-type' => 'application/json'));


The var_dump returned shows:

array(3) {

I’m pretty sure I’m doing something silly. I’ve tried sending in XML instead of JSON. I’ve tried using just a single array of params rather than the array in an array I’ve got in the sample. I’m going round in circles!

If someone could give me a little nudge in the right direction, I’d be eternally grateful!


I’ve fixed this already. Used CURL to send the data and it worked fine!