Created
February 6, 2012 20:01
-
-
Save adrianmott/1754457 to your computer and use it in GitHub Desktop.
HubSpot GoToWebinar Double Post from a form (not a HS landing page)
This file contains 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
System.Text.StringBuilder GTWoutput = new System.Text.StringBuilder(); | |
//GTW form elements | |
GTWoutput.Append("WebinarKey=" + Server.UrlEncode(Request.QueryString["WebinarKey"].ToString())); | |
GTWoutput.Append("&Form=webinarRegistrationForm"); | |
GTWoutput.Append("&Name_First=" + Server.UrlEncode(Request.QueryString["FirstName"].ToString())); | |
GTWoutput.Append("&Name_Last=" + Server.UrlEncode(Request.QueryString["LastName"].ToString())); | |
GTWoutput.Append("&Email=" + Server.UrlEncode(Request.QueryString["Email"].ToString())); | |
//get POST URL for GTW | |
string GTWurl = "https://www.gotomeeting.com/en_US/island/webinar/registration.flow"; | |
//build submission request | |
System.Net.HttpWebRequest GTWreq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(GTWurl); | |
GTWreq.Method = "POST"; //must HTTP POST to GTW | |
GTWreq.ProtocolVersion = System.Net.HttpVersion.Version10; //ASP.Net's implementation of HTTP 1.1 adds a layer that is impossible to work around with GTW's web service | |
GTWreq.ContentType = "application/x-www-form-urlencoded"; //look like a form submission | |
GTWreq.KeepAlive = false; | |
byte[] buffer = Encoding.ASCII.GetBytes(GTWoutput.ToString()); //convert our "form" to a stream-readable format | |
GTWreq.ContentLength = buffer.Length; | |
//stream out data over request | |
System.IO.Stream PostData = GTWreq.GetRequestStream(); | |
PostData.Write(buffer, 0, buffer.Length); //write to GTW | |
PostData.Close(); | |
System.Net.HttpWebResponse WebResp = (System.Net.HttpWebResponse)GTWreq.GetResponse(); //get a response from GTW for our request - this CONFIRMS the registration. Miss this step and it won't work. |
This file contains 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.aspx"> | |
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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment