...
<%@LANGUAGE="VBSCRIPT"%> <% on error resume next
Dim strEmail, intList, intGroup Dim xml, url, response_val
strEmail=request("email") ' user's email address intList=request("list") ' list ID intGroup=request("group") ' group to which to subscribe the user (optional) blnConfirm = 1 'Confirmation request csvFldNames = "Field1;Field2;Field3;Field4" 'Field names are taken from the Codes Table csvFldValues = "Name;Surname;Company;M" 'Values are assigned to the corresponding fields in the same order as csvFldNames retCode = 1 'if retCode = 1 the value returned by the request is an error code, if retCode = 0 error text is returned 'The page that will be called on our servers url="http://newsletter.domainname.tld/frontend/xmlSubscribe.aspx "
' XMLHTTP version 3.0: Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP") xml.Open "POST",url,false
' Request is sent xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" xml.Send "email=" & strEmail & "&list=" & intList & "&group=" & intGroup & "&confirm=" & blnConfirm & "&csvFldNames=" & csvFldNames& "&csvFldValues=" & csvFldValues & "&retCode=" & retCode
'If retCode = 1 returned values are the following: 'Returned values: '0 : Operation completed '1 : Generic error '2 : Invalid address '3 : User already subscribed if err.number=0 then 'Value returned by the call response_val=xml.responseText Set xml = Nothing else 'The call was unsuccessful (e.g. Network error). response_val=1 Set xml=nothing end if
' Once the value has been returned it is possible to decide what to do/view
Select Case response_val Case "0" 'Display a message saying the user was subscribed successfully '... Case "1" 'Display a message saying the service is not accessible at the moment '... Case "2" 'Display a message saying the email address in an invalid address '... Case "3" 'Display a message saying that the user is already subscribed Case Else 'Display a message saying the service is temporarily unavailable
End Select
'If retCode = 0 error text is returned ' Returned value is retrieved response_val=xml.responseText Set xml = Nothing
%> Windows Server (ASP.NET) |
The following code has been developed using C# language.
...