Created
January 21, 2014 21:20
-
-
Save ksnider/8548614 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 | |
| /* | |
| * 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? | |
| */ | |
| // Our custom error handler | |
| function our_error_handler($number, $message, $file, $line, $vars) | |
| { | |
| echo "<b>Error:</b> [$number] $message on line $line <br/>"; | |
| echo 'Ending script<br/><br/>'; | |
| $message = "$number $message on line $line"; | |
| error_log($message); | |
| $email = " | |
| <p>An error ($number) occurred on line | |
| <strong>$line</strong> and in the <strong>file: $file.</strong> | |
| <p> $message </p>"; | |
| $email .= "<pre>" . print_r($vars, 1) . "</pre>"; | |
| $headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; | |
| error_log($email, 1, '[email protected]', $headers); | |
| die; | |
| } | |
| // We want to use our custom function to handle errors. | |
| set_error_handler('our_error_handler'); | |
| // Trigger an error... (var doesn't exist) | |
| // echo $somevarthatdoesnotexist; | |
| // Connect to the Infusionsoft API | |
| require("isdk.php"); | |
| $app = new iSDK; | |
| if ($app->cfgCon("sandbox")) { | |
| // Current date in Infusionsoft-friendly format | |
| $currentDate = date_format(date_create(), 'Ymd H:i:s'); | |
| echo "You connected at $currentDate <br/>"; | |
| // Find the contact ID from the REQUEST variable | |
| if ($_SERVER[REQUEST_METHOD] == 'POST') { | |
| if (isset($_POST['contactId']) && $_POST['contactId'] != '') { | |
| $contactId = $_POST['contactId']; | |
| } else { echo 'Post is not set'; } | |
| } else { | |
| if ($_SERVER[REQUEST_METHOD] == 'GET') { | |
| if (isset($_GET['Id']) && $_GET['Id'] != '') { | |
| $contactId = $_GET['Id']; | |
| } else { echo 'Get is not set'; } | |
| } else { | |
| $result = 'Houston, we have an alien REQUEST METHOD!'; | |
| } | |
| } | |
| // what should we do to beef this up? If this fails, how would you know? | |
| } else { | |
| trigger_error("Not connected to Infusionsoft", E_USER_WARNING); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment