Skip to content

Instantly share code, notes, and snippets.

@ksnider
Last active December 29, 2015 12:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ksnider/7671972 to your computer and use it in GitHub Desktop.
Save ksnider/7671972 to your computer and use it in GitHub Desktop.
Parse a Name field and add results to Infusionsoft
<?php
// Connect to the Infusionsoft API
require("isdk.php");
$app = new iSDK;
$app->cfgCon("connectionName");
// Connect the required file from HumanNameParser
require_once('HumanNameParser/init.php');
// Get the contact ID
//$name = 'John F. Kennedy';
//$email = 'jfk@whitehourse.gov';
$name = $_POST['FullName'];
$email = $_POST['Email'];
// Instantiate a new parser object
$parser = new HumanNameParser_Parser($name);
// Use the methods to get First, Middle and Last
// Available methods are getleadingInit(), getFirst(), getNicknames(),
// getMiddle(), getLast() and getSuffix()
$fname = $parser->getFirst();
$mname = $parser->getMiddle();
$lname = $parser->getLast();
// Update contact record using AddWithDupCheck method
$data = array('FirstName' => $fname,
'MiddleName' => $mname,
'LastName' => $lname,
'Email' => $email);
$update = $app->addWithDupCheck($data, 'EmailAndName');
echo $update;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Web Form Test</title>
</head>
<body>
<!-- this tells the browser where and how to send the data from the form -->
<form action='parse-names.php' method='post' enctype="multipart/form-data">
Name : <input type='text' name='FullName'><br />
Email : <input type='text' name='Email' ><br />
<input type='submit' value='Submit'>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment