public static function getJavaScript($webFormId, Infusionsoft_App $app = null)
{
$app = parent::getObjectOrDefaultAppIfNull($app);
/*
* The API doesn't provide a method of getting the JavaScript snippet.
* Instead, we are going to get the HTML, find the form GUID, and create
* the JavaScript snippet 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 JavaScript snippet
$snippet = '<script type="text/javascript" src="https://';
$snippet .= $app->getHostname();
$snippet .= '/app/form/iframe/' . $guid . '"></script>';
return $snippet;
}