How to Enrich an Input Lead with Additional Data Fields in PHP

Today’s subject is enriching an input lead with more data fields. Instead of boring you with a detailed code analysis for this process, I am going to show you the easy way out. Basically it comes down to this: Why do all this hard work when an API is ready to do it for you? With one simple function call from our API, we can have things up and running. Let’s take a look.

Install the API client via the command line:

composer require cloudmersive/cloudmersive_validate_api_client

This will now allow us to run this function here:

<?phprequire_once(__DIR__ . '/vendor/autoload.php');// Configure API key authorization: Apikey$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('Apikey', 'YOUR_API_KEY');// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Apikey', 'Bearer');$apiInstance = new Swagger\Client\Api\LeadEnrichmentApi(// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.// This is optional, `GuzzleHttp\Client` will be used as default.new GuzzleHttp\Client(),$config);$request = new \Swagger\Client\Model\LeadEnrichmentRequest(); // \Swagger\Client\Model\LeadEnrichmentRequest | Input lead with known fields set, and unknown fields left blank (null)try {$result = $apiInstance->leadEnrichmentEnrichLead($request);print_r($result);} catch (Exception $e) {echo 'Exception when calling LeadEnrichmentApi->leadEnrichmentEnrichLead: ', $e->getMessage(), PHP_EOL;}?>

Well look at that, we are already done. Talk about painless!

Image for post
Image for post

Written by

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store