Skip to content
PHP Wrapper to use the API
Branch: develop
Clone or download
mavimo Merge pull request #106 from eengoron/develop
Change base url from to
Latest commit cfc8069 Mar 15, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Remove issue template May 10, 2018
src Change base url from to Mar 14, 2019
tests Change base url from to Mar 14, 2019
.coveralls.yml refs #43: fix coveralls reports and restructure phpunit config Apr 15, 2018
.editorconfig Add PHP 7.3 to the Travis CI build pipeline Jan 17, 2019
.gitignore Fix the code style of all files Oct 30, 2018
.php_cs Disable yoda style comparison Oct 31, 2018
.travis.yml Test against PHP 7.4snapshot instead of nightly Feb 27, 2019
LICENSE Update the README with more detailed docs on installation and usage Oct 1, 2018


License Build Status Coverage Status

Packagist Packagist Packagist Packagist

The CloseIo API Wrapper is a package that allows you to access in an object oriented way the REST APIs and fetch or create data.


To install the library you will need to be using Composer in your project. To install it please see the official docs. CloseIo Api Wrapper uses Httplug to not be tied to any specific library that sends HTTP messages. This means that users are free to choose whichever PSR-7 implementation and HTTP client they want, be it Guzzle or a simple cURL client.

If you just want to get started quickly you should run the following command:

composer require loopline-systems/closeio-api-wrapper php-http/curl-client nyholm/psr7

This will install the library itself along with an HTTP client adapter for Httplug that uses cURL and a PSR-7 implementation needed to create the messages. You do not need to use those packages if you don't want to: you may use any package that provides php-http/async-client-implementation and http-message-implementation.


To get started you just need to create an instance of the client and then use its method to query the REST APIs of

require_once __DIR__ . '/vendor/autoload.php';

use LooplineSystems\CloseIoApiWrapper\Client;
use LooplineSystems\CloseIoApiWrapper\CloseIoApiWrapper;
use LooplineSystems\CloseIoApiWrapper\Configuration;

$configuration = new Configuration('{api-key}');
$client = new Client($configuration);
$closeIoApiWrapper = new CloseIoApiWrapper($client);

$leadsApi = $closeIoApiWrapper->getLeadApi();

// create lead
$lead = new Lead();
$lead->setName('Test Company');
$lead->setDescription('Company description');

// address
$address = new Address();
$address->setAddress1('Main Street');

// contacts
$contact = new Contact();
$contact->setName('Testy Testersson');
$contact->setTitle('Chief Tester');

// emails
$email = new Email();

// phones
$phone = new Phone();


$response = $leadsApi->addLead($lead);

Adding Opportunities

$opportunity = new Opportunity();
$opportunity->setNote('My note on this opportunity');

// you can use the leadApi to get ID for leads

$opportunityApi = $this->apiWrapper->getOpportunityApi();
$result = $opportunityApi->addOpportunity($opportunity);


$activityApi = $this->apiWrapper->getActivityApi();
// SMS
$sms = new SmsActivity();
$sms->setText('first sms');

// EMails
$email = new EmailActivity();
$email->setSubject('RE: Support');
$email->setSender('Support <>');
$email->setTo('Customer <>');


Updating custom fields

$customField = new CustomField();
$customField->setId('Custom field id')
$customField->addChoice('Value for choices list');

$customFieldApi = $this->apiWrapper->getCustomFieldApi();
$result = $customFieldApi->updateCustomField($customField);


Right now just a few APIs are implemented, because the main need was to create leads. Feel free to add requests and create pull requests or go on forking the repository.

We use for our release names, so don't worry they have no special meaning :)


Michael Devery -
Marco Roßdeutscher -
Marc Zahn -

See also the list of contributors who participated in this project.


The API Wrapper is licensed under the MIT License: see the LICENSE file for more information.

! We are not affiliated with itself.

You can’t perform that action at this time.