/** * Get the web form's hosted URL. * * Instead of having to use the HTML code, you can get the URL to the * Infusionsoft hosted version of the web form. * * @author Jacob Allred <*****@*****.**> * * @param int $webFormId The ID from Infusionsoft_WebFormService::getMap. * @param Infusionsoft_App $app * @return string URL of hosted web form */ public static function getHostedURL($webFormId, Infusionsoft_App $app = null) { $app = parent::getObjectOrDefaultAppIfNull($app); /* * The API doesn't provide a method of getting the hosted URL. * Instead, we are going to get the HTML, find the form GUID, and create * the hosted URL on our own. */ // Get the HTML $html = Infusionsoft_WebFormService::getHTML($webFormId, $app); // Create our search string $search = $app->getHostname() . '/app/form/process/'; // Find the start and stop position of the form GUID $start = strpos($html, $search) + strlen($search); $stop = strpos(substr($html, $start), '"'); // Pull out the GUID $guid = substr($html, $start, $stop); // Put together the hosted URL $url = 'https://'; $url .= $app->getHostname(); $url .= '/app/form/' . $guid; return $url; }
<form> <input type="submit"> <input type="hidden" name="go"> </form> <?php include '../infusionsoft.php'; include 'testUtils.php'; if (isset($_REQUEST['go'])) { $out = Infusionsoft_WebFormService::getMap(); var_dump($out); }
<?php include "../infusionsoft.php"; include 'testUtils.php'; $webforms = Infusionsoft_WebFormService::getMap(Infusionsoft_AppPool::getApp()); foreach ($webforms as $webformId => $webformName) { ?> <h1>Webform: <?php echo $webformId . '-' . $webformName; ?> </h1> <?php echo Infusionsoft_WebFormService::getHTML($webformId, Infusionsoft_AppPool::getApp()); ?> <hr><?php }
include "../infusionsoft.php"; include 'testUtils.php'; $app = Infusionsoft_AppPool::getApp(); ?> Testing Host <?php echo $app->getHostname() . ':' . $app->getPort(); ?> with API Ping. <br /> <?php if (Infusionsoft_DataService::ping()) { ?> Ping Succeeded!!<br/><br/>Testing your API Key: by calling WebFormService.getMap. <br/> <?php try { Infusionsoft_WebFormService::getMap(Infusionsoft_AppPool::getApp()); ?> It Works! Everything is communicating properly and your API Key is correct.<?php } catch (Exception $e) { if (strpos($e->getMessage(), "[InvalidKey]") !== FALSE) { echo ' Failure!!! Your Key is not correct, please double check the key you put in the config.php with the APIKey in your apps Misc Settings.'; } else { echo ' Failure!!! Some other error: ' . $e->error; } } } else { ?> Something is wrong, see below for details, check your config file and try again. <?php }
/** * Get the web form's hosted URL. * * Instead of having to use the HTML code, you can get the URL to the * Infusionsoft hosted version of the web form. * * @author Jacob Allred <*****@*****.**> * * @param int $webFormId The ID from Infusionsoft_WebFormService::getMap. * @param Infusionsoft_App $app * @return string URL of hosted web form */ public static function getHostedURL($webFormId, Infusionsoft_App $app = null) { $app = parent::getObjectOrDefaultAppIfNull($app); /* * The API doesn't provide a method of getting the hosted URL. * Instead, we are going to get the HTML, find the form GUID, and create * the hosted URL on our own. */ // Get the HTML $html = Infusionsoft_WebFormService::getHTML($webFormId, $app); // Create our search string return self::getHostedUrlFromHtml($html, $app); }
<form> webformId: <input type="text" name="webformId" value="<?php if (isset($_REQUEST['webformId'])) { echo htmlspecialchars($_REQUEST['webformId']); } ?> "><br/> <input type="submit"> <input type="hidden" name="go"> </form> <?php include '../infusionsoft.php'; include 'testUtils.php'; if (isset($_REQUEST['go'])) { $out = Infusionsoft_WebFormService::getHTML($_REQUEST['webformId']); var_dump($out); }