Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.