Last active
January 2, 2016 18:09
-
-
Save ksnider/8341391 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * Note: This script is subject to all the disclaimers of 80/20 programming. Offered as-is | |
| * without warranty as to completeness or suitability | |
| * Most of us do not intend to become programmers. We just want to get simple things done quickly | |
| * and cost effectively. | |
| * It has to be secure but it doesn't have to be perfect | |
| * We may, at times, use deprecated code if it makes it easier/faster to read/learn | |
| * We may, at times, not have the most efficient code possible if it makes it easier/faster to read/learn | |
| * We will start with minimal error handling to make it easier/faster to read/learn. | |
| * If you plan to deploy this code on a client site, you will need to add error handling | |
| * as it will not die gracefully, as is. | |
| * As you do it more and more, you will do less and less of these | |
| */ | |
| /* | |
| * Sample project: | |
| * I need all new contacts entered into IS--whether by web form, order form, manual or | |
| * import to have their email * address set as their username, too. | |
| * I'd like to set that action as an action set that so that i can run it under | |
| * all ACTIONS and also give it to the admins to perform on imports. | |
| * I need help in creating that action, right now all I can do is set the username | |
| * to a specific value but can't see* where i can make that value be the email merge field. Any help? | |
| */ | |
| // Connect to the Infusionsoft API | |
| require("isdk.php"); | |
| $app = new iSDK; | |
| if ($app->cfgCon("sandbox")) { | |
| // Current date in Infusionsoft-friendly format | |
| echo "You connected at" . $currentDate = date("Ymd\TH:i:s") . "<br/>"; | |
| // Find the contact ID from the REQUEST variable | |
| // $contactId = $_REQUEST['contactId']; | |
| // $Id = $_REQUEST['Id']; | |
| // Determine whether 'Id' has been set by Action or 'contactId' by http post snippet | |
| if (isset($_REQUEST['Id'])) { | |
| $result = 'This was sent by an action'; | |
| // Assign contact's Id to a variable | |
| $contactId = $_REQUEST['Id']; | |
| } else { | |
| if (isset($_REQUEST['contactId'])) { | |
| $result = 'This was sent by a post snippet'; | |
| // Assign contact's Id to a variable | |
| $contactId = $_REQUEST['contactId']; | |
| } else { | |
| $result = 'Houston, we have a problem'; | |
| } | |
| } | |
| // API Call -> Load the email address of that contact | |
| $returnFields = array('Email'); | |
| $conDat = $app->loadCon($contactId, $returnFields); | |
| // API Call -> Put that email address in the username field | |
| $email = $conDat['Email']; | |
| $update = array('Username' => $email); | |
| $conID = $app->updateCon($contactId, $update); | |
| /* | |
| // Dump to file | |
| $file=fopen("kim_log.txt","a+"); | |
| fwrite($file, | |
| $conID | |
| . "\n"); | |
| $file=fclose($file); | |
| */ | |
| } else { | |
| echo "Not Connected..."; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment