I've read the posts about web forms and it surprises me how difficult such a simple thing could be. Bascially, I used Method to generate a Basic Web-To-Lead form and changed nothing. I then took the source code and took away all of the javascript and the form HTML tags and preserved the "id" values, including the hidden boxes. The next step should be very straight forward. Create an MSXML2.ServerXMLHTTP object, Open the object, set some parameters and send it away.
But for some reason, I keep getting the following annoying error:
We couldn't authenticate web form provider. Please contact web form provider for any additional information.
I read in a post on Method that the "timezonerouter.aspx" might cause some problems. So I tried submitting my test form (web2lead.asp) using it and not using it. The same issue arises.
Now, yes, ASP.NET certainly would be easier by using the Method API's web service. But unfortunately, I have not delved enough into ASP.NET to appreciate if I require code behind pages or a GUI on my page. So while it's ironic that I"m a present-day C# and .NET user, I still use good old classic ASP to get my data stuff done.
Here is my code. Hopefully someone at Method can give me some insight as to what I'm doing wrong here. It should work.
<% @LANGUAGE="VBScript" %>
<% Response.buffer = true %>
<%
'on error resume next
dim destURL
dim payload
' TRIED USING THE TIME ZONE ROUTER -> DOES NOT WORK.
'destURL = "https://www.methodintegration.com/method/timezonerouter.aspx?url=https://www.methodintegration.com/MethodWebForms/submit.aspx"
' SO WE'RE USING THIS INSTEAD AND ACCEPTING TIMESTAMPS IN EST
destURL = "https://www.methodintegration.com/MethodWebForms/submit.aspx"
'Construct the Post Data
payload = "oid=xxxxxxxxxxxxxxxxxxxxxxxx" ' note: THE XXXX's here are put here just for my post to Method Forum
payload = payload & "&formName=" & server.URLencode("Web-To-Lead")
payload = payload & "&redUrl=" & server.URLencode("http://")
payload = payload & "&BillAddressAddr3_Step2=" & server.URLencode("101 Some Street")
payload = payload & "&BillAddressCity_Step2=" & server.URLencode("Toronto")
payload = payload & "&BillAddressState_Step2=" & server.URLencode("Ontario")
payload = payload & "&BillAddressPostalCode_Step2=" & server.URLencode("M5N 2T3")
payload = payload & "&BillAddressCountry_Step2=" & server.URLencode("CA")
payload = payload & "&CompanyName_Step2=" & server.URLencode("ACME CORPORATION")
payload = payload & "&FirstName_Step2=" & server.URLencode("John")
payload = payload & "&LastName_Step2=" & server.URLencode("Doe")
payload = payload & "&Email_Step2=" & server.URLencode("john.doe@somedomain.com")
payload = payload & "&Phone_Step2=" & server.URLencode("9051234567")
payload = payload & "&Description_Step3=" & server.URLencode("these are my comments")
'Construct the useragent and send
set http_obj = server.CreateObject("MSXML2.ServerXMLHTTP")
http_obj.Open "POST", destURL , false
http_obj.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
http_obj.send(payload)
'Grab the response
strResponse = http_obj.ResponseText
set http_obj=nothing
Response.write(strResponse)
Response.end
%>
IT SURE WOULD BE NICE TO GET THIS WORKING :)