I'm using the Infusionsoft API with the Novak SDK.
I have a username
session value in my PHP website that matches a unique value inside a contact's custom field (also named username
). I'd like to use the session value from the website to query the Infusionsoft API, and have it return the unique contact record. Once I've gotten the contact record I'll want to determine the contact's ID. How do I do this?
I decided to rename and reappropriate the "first name" field (changing it to "username") instead of using a custom one.
Doing it that way I got some code to work:
<?php
// Include the SDK
require_once('Infusionsoft/infusionsoft.php');
//Get username value from session
$UserName = $_SESSION["Username"];
//Query contacts table using first name
$contacts = Infusionsoft_DataService::query(new Infusionsoft_Contact(), array('FirstName' => $UserName));
$contact = array_shift($contacts);
//This is the Contact ID
$contactID = $contact->Id;
//This is the Tag ID
$groupID = 105;
//Tag a user using the Contact ID and Tag ID
Infusionsoft_ContactService::addToGroup($contactID , $groupID);