PHP code example of loopline-systems / closeio-api-wrapper
1. Go to this page and download the library: Download loopline-systems/closeio-api-wrapper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
loopline-systems / closeio-api-wrapper example snippets
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');
$lead->setUrl('www.test-company.com');
// address
$address = new Address();
$address->setCountry('DE');
$address->setCity('Berlin');
$address->setAddress1('Main Street');
$address->setAddress2('Mitte');
// contacts
$contact = new Contact();
$contact->setName('Testy Testersson');
$contact->setTitle('Chief Tester');
// emails
$email = new Email();
$email->setEmail('[email protected]');
$email->setType(Email::EMAIL_TYPE_OFFICE);
$contact->addEmail($email);
// phones
$phone = new Phone();
$phone->setPhone('+491234567890');
$phone->setType(Phone::PHONE_TYPE_MOBILE);
$contact->addPhone($phone);
$lead->addAddress($address);
$lead->addContact($contact);
$response = $leadsApi->addLead($lead);
$opportunity = new Opportunity();
$opportunity->setValue(500);
$opportunity->setNote('My note on this opportunity');
$opportunity->setConfidence(85);
$opportunity->setValuePeriod(Opportunity::OPPORTUNITY_FREQUENCY_MONTHLY);
// you can use the leadApi to get ID for leads
$opportunity->setLeadId(<lead-id>);
$opportunityApi = $this->apiWrapper->getOpportunityApi();
$result = $opportunityApi->addOpportunity($opportunity);