# PHP Client Library

## Installation

To install via [Composer](http://getcomposer.org/):

```bash
composer require tomba-io/php
```

## Usage

### Domain Search

Get email addresses found on the internet.

```php
<?php

use Tomba\Client;
use Tomba\Services\Domain;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$domain = new Domain($client);

$result = $domain->domainSearch('stripe.com');
```

### Email Finder

Find the verified email address of any professional.

```php
<?php

use Tomba\Client;
use Tomba\Services\Finder;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$finder = new Finder($client);

$result = $finder->emailFinder('stripe.com', 'fname', 'lname');
```

### Email Verifier

Verify the validity of any professional email address with the most complete email checker.

```php
<?php

use Tomba\Client;
use Tomba\Services\Verifier;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$verifier = new Verifier($client);

$result = $verifier->emailVerifier('m@wordpress.org');
```

## Examples

### Get Account Information

```php
<?php

use Tomba\Client;
use Tomba\Services\Account;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$account = new Account($client);

$result = $account->getAccount();
```

### Email Count

```php
<?php

use Tomba\Client;
use Tomba\Services\Count;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$count = new Count($client);

$result = $count->emailCount('tomba.io');
```

### Finder Services

#### Author Finder

This API endpoint generates or retrieves the most likely email address from a blog post URL.

```php
<?php

use Tomba\Client;
use Tomba\Services\Finder;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$finder = new Finder($client);

$result = $finder->authorFinder('https://clearbit.com/blog/company-name-to-domain-api');
```

#### LinkedIn Finder

This API endpoint generates or retrieves the most likely email address from a LinkedIn URL.

```php
<?php

use Tomba\Client;
use Tomba\Services\Finder;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$finder = new Finder($client);

$result = $finder->linkedinFinder('https://www.linkedin.com/in/alex-maccaw-ab592978');
```

#### Phone Finder

This endpoint looks up phone data from an email address.

```php
<?php

use Tomba\Client;
use Tomba\Services\Finder;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$finder = new Finder($client);

$result = $finder->phoneFinder('******@zapier.com');
```

### API Key Management

#### Create API Key

```php
<?php

use Tomba\Client;
use Tomba\Services\Keys;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$keys = new Keys($client);

$result = $keys->createKey();
```

#### Delete API Key

```php
<?php

use Tomba\Client;
use Tomba\Services\Keys;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$keys = new Keys($client);

$result = $keys->deleteKey('');
```

#### Get All API Keys

```php
<?php

use Tomba\Client;
use Tomba\Services\Keys;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$keys = new Keys($client);

$result = $keys->getKeys();
```

#### Reset API Key

```php
<?php

use Tomba\Client;
use Tomba\Services\Keys;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$keys = new Keys($client);

$result = $keys->resetKey('');
```

### Lead Attributes Management

#### Create Lead Attribute

```php
<?php

use Tomba\Client;
use Tomba\Services\LeadsAttributes;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$leadsAttributes = new LeadsAttributes($client);

$result = $leadsAttributes->createLeadAttribute();
```

#### Delete Lead Attribute

```php
<?php

use Tomba\Client;
use Tomba\Services\LeadsAttributes;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$leadsAttributes = new LeadsAttributes($client);

$result = $leadsAttributes->deleteLeadAttribute('[Lead_Attributes_ID]');
```

#### Get Lead Attributes

```php
<?php

use Tomba\Client;
use Tomba\Services\LeadsAttributes;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$leadsAttributes = new LeadsAttributes($client);

$result = $leadsAttributes->getLeadAttributes();
```

#### Update Lead Attribute

```php
<?php

use Tomba\Client;
use Tomba\Services\LeadsAttributes;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$leadsAttributes = new LeadsAttributes($client);

$result = $leadsAttributes->updateLeadAttribute('[Lead_Attributes_ID]');
```

### Lead Lists Management

#### Create Lead List

```php
<?php

use Tomba\Client;
use Tomba\Services\LeadsLists;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$leadsLists = new LeadsLists($client);

$result = $leadsLists->createList();
```

#### Delete Lead List

```php
<?php

use Tomba\Client;
use Tomba\Services\LeadsLists;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$leadsLists = new LeadsLists($client);

$result = $leadsLists->deleteListId('[LIST_ID]');
```

#### Get All Lead Lists

```php
<?php

use Tomba\Client;
use Tomba\Services\LeadsLists;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$leadsLists = new LeadsLists($client);

$result = $leadsLists->getLists();
```

#### Update Lead List

```php
<?php

use Tomba\Client;
use Tomba\Services\LeadsLists;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$leadsLists = new LeadsLists($client);

$result = $leadsLists->updateListId('[List_ID]');
```

### Activity Logs

```php
<?php

use Tomba\Client;
use Tomba\Services\Logs;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$logs = new Logs($client);

$result = $logs->getLogs();
```

### Email Sources

```php
<?php

use Tomba\Client;
use Tomba\Services\Sources;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$sources = new Sources($client);

$result = $sources->emailSources('b.mohamed@tomba.io');
```

### Domain and Company Status

#### Auto Complete

```php
<?php

use Tomba\Client;
use Tomba\Services\Status;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$status = new Status($client);

$result = $status->autoComplete('google');
```

#### Domain Status

```php
<?php

use Tomba\Client;
use Tomba\Services\Status;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$status = new Status($client);

$result = $status->domainStatus('gmail.com');
```

### Usage Statistics

```php
<?php

use Tomba\Client;
use Tomba\Services\Usage;

$client = new Client();

$client
    ->setKey('ta_xxxx') // Your API Key
    ->setSecret('ts_xxxx') // Your Secret
;

$usage = new Usage($client);

$result = $usage->getUsage();
```

For more sample codes, check the [**examples/**](https://github.com/tomba-io/php/tree/master/examples) folder.
