Created
February 6, 2012 19:58
-
-
Save adrianmott/1754443 to your computer and use it in GitHub Desktop.
HubSpot GoToWebinar Double Post from a form (not a HS landing page)
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 | |
if ($_SERVER['REQUEST_METHOD'] == "GET") { | |
header('Location:http://thefreshdish.com'); | |
$gtwPost = ""; | |
//Create string for GoToWebinar from same form POST data | |
$gtwPost = "WebinarKey=" . urlencode($_GET['WebinarKey']) | |
. "&Form=" . urlencode($_GET['Form']) | |
. "&Name_First=" . urlencode($_GET['firstName']) | |
. "&Name_Last=" . urlencode($_GET['lastName']) | |
. "&Email=" . urlencode($_GET['email']); | |
//Set POST URL for GoToWebinar | |
$gtw_url = "https://www1.gotomeeting.com/en_US/island/webinar/registration.flow"; | |
//Start GoToWebinar submission | |
$curl = @curl_init(); | |
@curl_setopt($curl, CURLOPT_POSTFIELDS, $gtwPost); | |
@curl_setopt($curl, CURLOPT_URL, $gtw_url); | |
@curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); | |
@curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); | |
@curl_exec($curl); | |
$info = @curl_getinfo($curl); | |
@curl_close($curl); | |
//End GoToWebinar registrant submission | |
//START HubSpot Lead Submission | |
$strPost = ""; | |
//create string for HubSpot with form POST data | |
$strPost = "FirstName=" . urlencode($_GET['firstName']) | |
. "&LastName=" . urlencode($_GET['lastName']) | |
. "&Email=" . urlencode($_GET['email']) | |
. "&IPAddress=" . urlencode($_SERVER['REMOTE_ADDR']) | |
. "&UserToken=" . urlencode($_COOKIE['hubspotutk']); | |
//set POST URL for HubSpot | |
$hubspot_url = "http://amott.app5.hubspot.com/?app=leaddirector&FormName=GTW+Process"; | |
//intialize cURL and send POST data | |
$ch = @curl_init(); | |
@curl_setopt($ch, CURLOPT_POSTFIELDS, $strPost); | |
@curl_setopt($ch, CURLOPT_URL, $hubspot_url); | |
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
@curl_exec($ch); | |
@curl_close($ch); | |
//END HubSpot Lead Submission | |
} | |
?> |
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
<form method="get" action="http://<path-to-file>/gtw-process.php"> | |
First Name: <input name="firstName" size="40" type="text" /> | |
Last Name: <input name="lastName" size="40" type="text" /> | |
Email: <input name="email" size="40" type="text" /> | |
<input name="WebinarKey" type="hidden" value='<ENTER WEBINAR KEY HERE>' /> | |
<input name="Form" type="hidden" value="webinarRegistrationForm" /> | |
<input name="Template" type="hidden" value="https://www1.gotomeeting.com/en_US/island/webinar/registration.tmpl" /> | |
<input type="submit" value="Submit" /> | |
</form> |
Is it based off of the url to the hubspot form?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pardon the stupid question... How exactly does this know where to post the info to hubspot? I guess I'm referring to how does it know what hubspot account to post the info to?