AxSms.Http
Introduction
Skip to properties and methods
Many bulk SMS providers or SMSCs provide a custom, HTTP-based interface for customers to send SMS messages.
Providers often use an HTTP-based custom interface because of its simplicity compared to more complex protocols like SMPP. Performance is roughly comparable to SMPP for medium to large volumes.
The drawback of using HTTP is that it only allows sending SMS messages. If you need to receive SMS messages or delivery reports, you must set up an HTTP server to receive HTTP requests from the SMSC.
The Http object in the SMS Component supports most HTTP providers. For simple provider configurations you can set the Url and PostBody templates and use the SendSms method to send SMS messages. For more complex configurations the Http object provides Post and Get methods so you can create your own URL or post body layout independent of the SMS message object.
Properties and Methods
| Property | Type | Read/Write | Description |
| Version | String | Read | Version number of the SMS Component |
| Build | String | Read | Build number of the SMS Component |
| Module | String | Read | Module name of the SMS Component |
| LicenseStatus | String | Read | License Status |
| LicenseKey | String | Read/Write | License Key |
| LastError | Number | Read | Result of the last called method |
| LogFile | String | Read/Write | The path to a logfile which can be used for troubleshooting |
| WebAccount | String | Read/Write | Web login account if required |
| WebPassword | String | Read/Write | Web password if required |
| ProxyServer | String | Read/Write | ProxyServer URL if required |
| ProxyAccount | String | Read/Write | Proxy login account if required |
| ProxyPassword | String | Read/Write | Proxy password if required |
| LastResponseCode | Number | Read | Last response code returned by the server |
| RequestTimeout | Number | Read/Write | Request timeout in milliseconds |
| Url | String | Read/Write | Default URL, including placeholders, when sending text messages |
| PostBody | String | Read/Write | Default Post body, including placeholders, when sending text messages |
| Method | Description |
| Clear | Reset all properties to their default values |
| SaveLicenseKey | Save the License Key in the registry |
| GetErrorDescription | Get the description of the given error |
| Sleep | Sleep for the specified number of milliseconds |
| SetHeader | Set HTTP header to be sent |
| Get | Get a web page |
| Post | Post a post body to a web server |
| Download | Download a file from a web server |
| SendSms | Send a text message through this HTTP connection |
| UrlEncode | URL encode the given string |
| HexEncode | Hex encode the given string |
| Base64Encode | Base64 encode the given string |
| Base64EncodeFile | Base64 encode the given file |
Version property
Returns the version number of the SMS Component.
Example:
$objHttp = New-Object -ComObject AxSms.Http
Write-Host "SMS Component Version $($objHttp.Version); Build $($objHttp.Build); " `
"Module $($objHttp.Module)"
Write-Host "License Status: $($objHttp.LicenseStatus)`n"
...
var objHttp = new AxSms.Http();
Console.WriteLine($"SMS Component Version {objHttp.Version}; Build {objHttp.Build}; " +
$"Module {objHttp.Module}");
Console.WriteLine($"License Status: {objHttp.LicenseStatus}\n");
...
Set objHttp = CreateObject("AxSms.Http")
WScript.Echo "SMS Component Version " & objHttp.Version & "; Build " & _
objHttp.Build & "; Module " & objHttp.Module
WScript.Echo "License Status: " & objHttp.LicenseStatus & vbCrLf
...
Build property
Returns the build number of the SMS Component.
Example:
$objHttp = New-Object -ComObject AxSms.Http
Write-Host "SMS Component Version $($objHttp.Version); Build $($objHttp.Build); " `
"Module $($objHttp.Module)"
Write-Host "License Status: $($objHttp.LicenseStatus)`n"
...
var objHttp = new AxSms.Http();
Console.WriteLine($"SMS Component Version {objHttp.Version}; Build {objHttp.Build}; " +
$"Module {objHttp.Module}");
Console.WriteLine($"License Status: {objHttp.LicenseStatus}\n");
...
Set objHttp = CreateObject("AxSms.Http")
WScript.Echo "SMS Component Version " & objHttp.Version & "; Build " & _
objHttp.Build & "; Module " & objHttp.Module
WScript.Echo "License Status: " & objHttp.LicenseStatus & vbCrLf
...
Module property
Returns the module name of the SMS Component.
Example:
$objHttp = New-Object -ComObject AxSms.Http
Write-Host "SMS Component Version $($objHttp.Version); Build $($objHttp.Build); " `
"Module $($objHttp.Module)"
Write-Host "License Status: $($objHttp.LicenseStatus)`n"
...
var objHttp = new AxSms.Http();
Console.WriteLine($"SMS Component Version {objHttp.Version}; Build {objHttp.Build}; " +
$"Module {objHttp.Module}");
Console.WriteLine($"License Status: {objHttp.LicenseStatus}\n");
...
Set objHttp = CreateObject("AxSms.Http")
WScript.Echo "SMS Component Version " & objHttp.Version & "; Build " & _
objHttp.Build & "; Module " & objHttp.Module
WScript.Echo "License Status: " & objHttp.LicenseStatus & vbCrLf
...
LicenseStatus property
The status of your license. If you have not licensed the product yet, the property holds the trial expiration date. For details, see Product Activation.
Example:
$objHttp = New-Object -ComObject AxSms.Http # Create new instance
Write-Host "License Status: $($objHttp.LicenseStatus)"
Write-Host "License Key: $($objHttp.LicenseKey)"
var objHttp = new AxSms.Http(); // Create new instance
Console.WriteLine($"License Status: {objHttp.LicenseStatus}");
Console.WriteLine($"License Key: {objHttp.LicenseKey}");
Set objHttp = CreateObject("AxSms.Http") ' Create new instance
WScript.Echo "License Status: " & objHttp.LicenseStatus
WScript.Echo "License Key: " & objHttp.LicenseKey
LicenseKey property
A license key is required to unlock this component after the trial period has expired. Assign the LicenseKey property every time you create a new instance of this component (see code below). Alternatively, the LicenseKey property can be set automatically when the license key is stored in the registry. For details, see Product Activation.
Example:
$objHttp = New-Object -ComObject AxSms.Http # Create new instance
$objHttp.LicenseKey = "XXXXX-XXXXX-XXXXX" # Assign your license key
Write-Host "LicenseKey: $($objHttp.LicenseKey)"
var objHttp = new AxSms.Http(); // Create new instance
objHttp.LicenseKey = "XXXXX-XXXXX-XXXXX"; // Assign your license key
Console.WriteLine($"LicenseKey: {objHttp.LicenseKey}");
Set objHttp = CreateObject("AxSms.Http") ' Create new instance
objHttp.LicenseKey = "XXXXX-XXXXX-XXXXX" ' Assign your license key
WScript.Echo "LicenseKey: " & objHttp.LicenseKey
LastError property
Completion code of the last called method. To find the error description of a given error code, go to the online error codes page.
Example:
$objHttp = New-Object -ComObject AxSms.Http
...
$objMessage = New-Object -ComObject AxSms.Message
$objMessage.ToAddress = "+31611223344"
$objMessage.Body = "Short text message"
$objHttp.SendSms($objMessage)
Write-Host "Send SMS result: $($objHttp.LastError)" # Is our message sent ?
...
var objHttp = new AxSms.Http();
...
var objMessage = new AxSms.Message();
objMessage.ToAddress = "+31611223344";
objMessage.Body = "Short text message";
objHttp.SendSms(objMessage);
Console.WriteLine($"Send SMS result: {objHttp.LastError}"); // Is our message sent ?
...
Set objHttp = CreateObject("AxSms.Http")
...
Set objMessage = CreateObject("AxSms.Message")
objMessage.ToAddress = "+31611223344"
objMessage.Body = "Short text message"
objHttp.SendSms objMessage
WScript.Echo "Send SMS result: " & objHttp.LastError ' Is our message sent ?
...
LogFile property
By default, LogFile holds an empty string and nothing is logged. If you assign a valid file name, the SMS Component writes debug information to this file. Output data is appended to the end of the file.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objHttp.LogFile = "C:\temp\log.txt"
...
$objMessage = New-Object -ComObject AxSms.Message
$objMessage.ToAddress = "+31611223344"
$objMessage.Body = "Short text message"
$objHttp.SendSms($objMessage)
...
var objHttp = new AxSms.Http();
objHttp.LogFile = @"C:\temp\log.txt";
...
var objMessage = new AxSms.Message();
objMessage.ToAddress = "+31611223344";
objMessage.Body = "Short text message";
objHttp.SendSms(objMessage);
...
Set objHttp = CreateObject("AxSms.Http")
objHttp.LogFile = "C:\temp\log.txt"
...
Set objMessage = CreateObject("AxSms.Message")
objMessage.ToAddress = "+31611223344"
objMessage.Body = "Short text message"
objHttp.SendSms objMessage
...
WebAccount property
Set the web login account if required.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$objHttp.WebAccount = "Account"
$objHttp.WebPassword = "Password"
...
$objHttp.SendSms($objMessage)
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
objHttp.WebAccount = "Account";
objHttp.WebPassword = "Password";
...
objHttp.SendSms(objMessage);
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
objHttp.WebAccount = "Account"
objHttp.WebPassword = "Password"
...
objHttp.SendSms objMessage
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
WebPassword property
Set the web login password if required.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$objHttp.WebAccount = "Account"
$objHttp.WebPassword = "Password"
...
$objHttp.SendSms($objMessage)
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
objHttp.WebAccount = "Account";
objHttp.WebPassword = "Password";
...
objHttp.SendSms(objMessage);
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
objHttp.WebAccount = "Account"
objHttp.WebPassword = "Password"
...
objHttp.SendSms objMessage
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
ProxyServer property
Set the proxy server if required.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$objHttp.ProxyServer = "proxy.domain.com:8080"
$objHttp.ProxyAccount = "Account"
$objHttp.ProxyPassword = "Password"
...
$objHttp.SendSms($objMessage)
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
objHttp.ProxyServer = "proxy.domain.com:8080";
objHttp.ProxyAccount = "Account";
objHttp.ProxyPassword = "Password";
...
objHttp.SendSms(objMessage);
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
objHttp.ProxyServer = "proxy.domain.com:8080"
objHttp.ProxyAccount = "Account"
objHttp.ProxyPassword = "Password"
...
objHttp.SendSms objMessage
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
ProxyAccount property
Set the proxy server login if required.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$objHttp.ProxyServer = "proxy.domain.com:8080"
$objHttp.ProxyAccount = "Account"
$objHttp.ProxyPassword = "Password"
...
$objHttp.SendSms($objMessage)
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
objHttp.ProxyServer = "proxy.domain.com:8080";
objHttp.ProxyAccount = "Account";
objHttp.ProxyPassword = "Password";
...
objHttp.SendSms(objMessage);
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
objHttp.ProxyServer = "proxy.domain.com:8080"
objHttp.ProxyAccount = "Account"
objHttp.ProxyPassword = "Password"
...
objHttp.SendSms objMessage
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
ProxyPassword property
Set the proxy server password if required.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$objHttp.ProxyServer = "proxy.domain.com:8080"
$objHttp.ProxyAccount = "Account"
$objHttp.ProxyPassword = "Password"
...
$objHttp.SendSms($objMessage)
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
objHttp.ProxyServer = "proxy.domain.com:8080";
objHttp.ProxyAccount = "Account";
objHttp.ProxyPassword = "Password";
...
objHttp.SendSms(objMessage);
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
objHttp.ProxyServer = "proxy.domain.com:8080"
objHttp.ProxyAccount = "Account"
objHttp.ProxyPassword = "Password"
...
objHttp.SendSms objMessage
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
LastResponseCode property
This property is set to the last response code received from the server.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$objHttp.SendSms($objMessage)
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
Write-Host $objHttp.LastResponseCode
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
objHttp.SendSms(objMessage);
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Console.WriteLine(objHttp.LastResponseCode);
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
objHttp.SendSms objMessage
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
WScript.Echo objHttp.LastResponseCode
RequestTimeout property
This is the request timeout in milliseconds.
The default request timeout is 10000 milliseconds.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$objHttp.RequestTimeout = 50000
$objHttp.SendSms($objMessage)
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
objHttp.RequestTimeout = 50000;
objHttp.SendSms(objMessage);
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
objHttp.RequestTimeout = 50000
objHttp.SendSms objMessage
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
Url property
This is the default URL used when sending text messages through SendSms.
Use these placeholders to insert dynamic fields into the URL.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objConst = New-Object -ComObject AxSms.Constants
$objMessage = New-Object -ComObject AxSms.Message
...
$objHttp.Url = "http://gateway.auronsoftware.com:8080/sendsms/default.asp"
$objHttp.PostBody = "username=CE658B84&password=FAC1982E&text=" + `
$objConst.HTTP_PLACEHOLDER_BODY + "&to=" + $objConst.HTTP_PLACEHOLDER_TOADDRESS
...
$objHttp.SendSms($objMessage)
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
var objHttp = new AxSms.Http();
var objConst = new AxSms.Constants();
var objMessage = new AxSms.Message();
...
objHttp.Url = "http://gateway.auronsoftware.com:8080/sendsms/default.asp";
objHttp.PostBody = "username=CE658B84&password=FAC1982E&text=" +
objConst.HTTP_PLACEHOLDER_BODY + "&to=" + objConst.HTTP_PLACEHOLDER_TOADDRESS;
...
objHttp.SendSms(objMessage);
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
objHttp.Url = "http://gateway.auronsoftware.com:8080/sendsms/default.asp"
objHttp.PostBody = "username=CE658B84&password=FAC1982E&text=" & _
objConst.HTTP_PLACEHOLDER_BODY & "&to=" & objConst.HTTP_PLACEHOLDER_TOADDRESS
...
objHttp.SendSms objMessage
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
PostBody property
This is the default Post body used when sending text messages through SendSms.
Use these placeholders to insert dynamic fields into the Post body.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objConst = New-Object -ComObject AxSms.Constants
$objMessage = New-Object -ComObject AxSms.Message
...
$objHttp.Url = "http://gateway.auronsoftware.com:8080/sendsms/default.asp"
$objHttp.PostBody = "username=CE658B84&password=FAC1982E&text=" + `
$objConst.HTTP_PLACEHOLDER_BODY + "&to=" + $objConst.HTTP_PLACEHOLDER_TOADDRESS
...
$objHttp.SendSms($objMessage)
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
var objHttp = new AxSms.Http();
var objConst = new AxSms.Constants();
var objMessage = new AxSms.Message();
...
objHttp.Url = "http://gateway.auronsoftware.com:8080/sendsms/default.asp";
objHttp.PostBody = "username=CE658B84&password=FAC1982E&text=" +
objConst.HTTP_PLACEHOLDER_BODY + "&to=" + objConst.HTTP_PLACEHOLDER_TOADDRESS;
...
objHttp.SendSms(objMessage);
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
objHttp.Url = "http://gateway.auronsoftware.com:8080/sendsms/default.asp"
objHttp.PostBody = "username=CE658B84&password=FAC1982E&text=" & _
objConst.HTTP_PLACEHOLDER_BODY & "&to=" & objConst.HTTP_PLACEHOLDER_TOADDRESS
...
objHttp.SendSms objMessage
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
Clear method
This method resets all properties to their default values.
Parameters:
- None
Return value:
Always returns 0.
Example:
$objHttp = New-Object -ComObject AxSms.Http
....
$objHttp.Clear()
...
var objHttp = new AxSms.Http();
....
objHttp.Clear();
...
Set objHttp = CreateObject("AxSms.Http")
....
objHttp.Clear
...
SaveLicenseKey method
Description:
Use SaveLicenseKey to store the license key permanently in the registry. When a license key is saved, it is restored automatically every time you create a new instance of the object. It is not recommended to save the license key if you distribute the component with your own software, because the key can be easily used by others.
Parameters:
- None.
Return value:
Always returns 0. Check the LastError property to see if the method completed successfully.
Example:
$objHttp = New-Object -ComObject AxSms.Http # Create new instance
$objHttp.LicenseKey = "XXXXX-XXXXX-XXXXX"
$objHttp.SaveLicenseKey() # Save license key to registry
var objHttp = new AxSms.Http(); // Create new instance
objHttp.LicenseKey = "XXXXX-XXXXX-XXXXX";
objHttp.SaveLicenseKey(); // Save license key to registry
Set objHttp = CreateObject("AxSms.Http") ' Create new instance
objHttp.LicenseKey = "XXXXX-XXXXX-XXXXX"
objHttp.SaveLicenseKey ' Save license key to registry
For more information, see Product Activation.
GetErrorDescription method
GetErrorDescription provides the error description of a given error code.
Parameters:
- The error code
Return value:
The error string.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objHttp.LogFile = "C:\temp\log.txt"
...
$objMessage = New-Object -ComObject AxSms.Message
$objMessage.ToAddress = "+31611223344"
$objMessage.Body = "Short text message"
$objHttp.SendSms($objMessage)
Write-Host "SendSms result: $($objHttp.LastError), " `
"$($objHttp.GetErrorDescription($objHttp.LastError))"
var objHttp = new AxSms.Http();
objHttp.LogFile = @"C:\temp\log.txt";
...
var objMessage = new AxSms.Message();
objMessage.ToAddress = "+31611223344";
objMessage.Body = "Short text message";
objHttp.SendSms(objMessage);
Console.WriteLine($"SendSms result: {objHttp.LastError}, " +
$"{objHttp.GetErrorDescription(objHttp.LastError)}");
Set objHttp = CreateObject("AxSms.Http")
objHttp.LogFile = "C:\temp\log.txt"
...
Set objMessage = CreateObject("AxSms.Message")
objMessage.ToAddress = "+31611223344"
objMessage.Body = "Short text message"
objHttp.SendSms objMessage
WScript.Echo "SendSms result: " & objHttp.LastError & ", " & _
objHttp.GetErrorDescription(objHttp.LastError)
Sleep method
This method suspends the current thread for the specified number of milliseconds.
Parameters:
- Milliseconds to sleep
Return value:
Always returns 0.
Example:
$objHttp = New-Object -ComObject AxSms.Http
....
$objHttp.Sleep(1000)
...
var objHttp = new AxSms.Http();
....
objHttp.Sleep(1000);
...
Set objHttp = CreateObject("AxSms.Http")
....
objHttp.Sleep 1000
...
SetHeader method
Set a custom HTTP header which will be included in future requests or posts made to a web server. The header value will clear any header value of the same name that was previously set. To clear all header values call the Clear method.
Parameters:
- Header – Name of the header
- Value – Header value
Return value:
None
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$objHttp.SetHeader("Content-Type", "application/x-www-form-urlencoded")
...
$strResponse = $objHttp.Post( `
"http://gateway.auronsoftware.com:8080/sendsms/default.asp", `
"username=CE658B84&password=FAC1982E&text=" + `
$objHttp.UrlEncode($objMessage.Body) + "&to=" + `
$objHttp.UrlEncode($objMessage.ToAddress))
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
Write-Host $strResponse
...
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
objHttp.SetHeader("Content-Type", "application/x-www-form-urlencoded");
...
string strResponse = objHttp.Post(
"http://gateway.auronsoftware.com:8080/sendsms/default.asp",
"username=CE658B84&password=FAC1982E&text=" +
objHttp.UrlEncode(objMessage.Body) + "&to=" +
objHttp.UrlEncode(objMessage.ToAddress));
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Console.WriteLine(strResponse);
...
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
objHttp.SetHeader("Content-Type", "application/x-www-form-urlencoded")
...
strResponse = objHttp.Post( _
"http://gateway.auronsoftware.com:8080/sendsms/default.asp", _
"username=CE658B84&password=FAC1982E&text=" & _
objHttp.UrlEncode(objMessage.Body) & _
"&to=" & objHttp.UrlEncode(objMessage.ToAddress))
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
WScript.Echo strResponse
...
Get method
Get the contents of a web page from a web server and return it as a string value. This method defaults to non-secure connections using the default HTTP port 80. You can specify SSL or a different port as usual, for example https://cruisecontrol.intra:8080/dashboard connects securely on port 8080.
Parameters:
- URL
Return value:
The requested website as a string value.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$strResponse = $objHttp.Get( `
"http://gateway.auronsoftware.com:8080/sendsms/default.asp?" + `
"username=CE658B84&password=FAC1982E&text=" + `
$objHttp.UrlEncode($objMessage.Body) + "&to=" + `
$objHttp.UrlEncode($objMessage.ToAddress))
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
Write-Host $strResponse
...
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
string strResponse = objHttp.Get(
"http://gateway.auronsoftware.com:8080/sendsms/default.asp?" +
"username=CE658B84&password=FAC1982E&text=" +
objHttp.UrlEncode(objMessage.Body) + "&to=" +
objHttp.UrlEncode(objMessage.ToAddress));
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Console.WriteLine(strResponse);
...
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
strResponse = objHttp.Get( _
"http://gateway.auronsoftware.com:8080/sendsms/default.asp?" & _
"username=CE658B84&password=FAC1982E&text=" & _
objHttp.UrlEncode(objMessage.Body) & _
"&to=" & objHttp.UrlEncode(objMessage.ToAddress))
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
WScript.Echo strResponse
...
Post method
Post a string to a website and return the result as a string value. This method defaults to non-secure connections using the default HTTP port 80. You can specify SSL or a different port as usual, for example https://cruisecontrol.intra:8080/dashboard connects securely on port 8080.
Parameters:
- Url
- Post body
Return value:
The requested website as a string value.
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$strResponse = $objHttp.Post( `
"http://gateway.auronsoftware.com:8080/sendsms/default.asp", `
"username=CE658B84&password=FAC1982E&text=" + `
$objHttp.UrlEncode($objMessage.Body) + "&to=" + `
$objHttp.UrlEncode($objMessage.ToAddress))
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
Write-Host $strResponse
...
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
string strResponse = objHttp.Post(
"http://gateway.auronsoftware.com:8080/sendsms/default.asp",
"username=CE658B84&password=FAC1982E&text=" +
objHttp.UrlEncode(objMessage.Body) + "&to=" +
objHttp.UrlEncode(objMessage.ToAddress));
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Console.WriteLine(strResponse);
...
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
strResponse = objHttp.Post("http://gateway.auronsoftware.com:8080/sendsms/default.asp", _
"username=CE658B84&password=FAC1982E&text=" & objHttp.UrlEncode(objMessage.Body) & _
"&to=" & objHttp.UrlEncode(objMessage.ToAddress))
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
WScript.Echo strResponse
...
Download method
Download a text or binary file from a web server. Use this method to download image or other media files.
Parameters:
- Url
- Target path
Return value:
None
Example:
$objHttp = New-Object -ComObject AxSms.Http
...
$objHttp.Download("https://whatsapp.someprovider:8080/media/3hudu32o3ikdj44u.mp4", `
"c:\server\media\3hudu32o3ikdj44u.mp4")
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
...
var objHttp = new AxSms.Http();
...
objHttp.Download("https://whatsapp.someprovider:8080/media/3hudu32o3ikdj44u.mp4",
@"c:\server\media\3hudu32o3ikdj44u.mp4");
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
...
Set objHttp = CreateObject("AxSms.Http")
...
objHttp.Download("https://whatsapp.someprovider:8080/media/3hudu32o3ikdj44u.mp4", _
"c:\server\media\3hudu32o3ikdj44u.mp4")
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
...
SendSms method
This method sends an SMS through HTTP by replacing the placeholders in the Url and PostBody parameters. If the PostBody parameter is not set it will use a ‘GET’ request type, otherwise a ‘POST’ request type will be used.
Parameters:
- SMS Message object
- (Optional) Multipart flag, can be one of these constants
Return value:
The server response
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objConst = New-Object -ComObject AxSms.Constants
$objMessage = New-Object -ComObject AxSms.Message
...
$objHttp.Url = "http://gateway.auronsoftware.com:8080/sendsms/default.asp"
$objHttp.PostBody = "username=CE658B84&password=FAC1982E&text=" + `
$objConst.HTTP_PLACEHOLDER_BODY + "&to=" + $objConst.HTTP_PLACEHOLDER_TOADDRESS
...
Write-Host $objHttp.SendSms($objMessage)
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
var objHttp = new AxSms.Http();
var objConst = new AxSms.Constants();
var objMessage = new AxSms.Message();
...
objHttp.Url = "http://gateway.auronsoftware.com:8080/sendsms/default.asp";
objHttp.PostBody = "username=CE658B84&password=FAC1982E&text=" +
objConst.HTTP_PLACEHOLDER_BODY + "&to=" + objConst.HTTP_PLACEHOLDER_TOADDRESS;
...
Console.WriteLine(objHttp.SendSms(objMessage));
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
objHttp.Url = "http://gateway.auronsoftware.com:8080/sendsms/default.asp"
objHttp.PostBody = "username=CE658B84&password=FAC1982E&text=" & _
objConst.HTTP_PLACEHOLDER_BODY & "&to=" & objConst.HTTP_PLACEHOLDER_TOADDRESS
...
WScript.Echo objHttp.SendSms(objMessage)
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
UrlEncode method
Use this method to URL encode parameters before adding them to the URL or Post body.
Parameters:
- The string to encode
Return value:
The encoded string
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$strResponse = $objHttp.Get( `
"http://gateway.auronsoftware.com:8080/sendsms/default.asp?" + `
"username=CE658B84&password=FAC1982E&text=" + `
$objHttp.UrlEncode($objMessage.Body) + "&to=" + `
$objHttp.UrlEncode($objMessage.ToAddress))
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
Write-Host $strResponse
...
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
string strResponse = objHttp.Get(
"http://gateway.auronsoftware.com:8080/sendsms/default.asp?" +
"username=CE658B84&password=FAC1982E&text=" +
objHttp.UrlEncode(objMessage.Body) + "&to=" +
objHttp.UrlEncode(objMessage.ToAddress));
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Console.WriteLine(strResponse);
...
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
strResponse = objHttp.Get( _
"http://gateway.auronsoftware.com:8080/sendsms/default.asp?" & _
"username=CE658B84&password=FAC1982E&text=" & _
objHttp.UrlEncode(objMessage.Body) & _
"&to=" & objHttp.UrlEncode(objMessage.ToAddress))
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
WScript.Echo strResponse
...
HexEncode method
Use this method to Hex encode strings before adding them as a GET argument or POST body.
Parameters:
- The string to encode
Return value:
The encoded string
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$strResponse = $objHttp.Get( `
"http://gateway.auronsoftware.com:8080/sendsms/default.asp?" + `
"username=CE658B84&password=FAC1982E&text=" + `
$objHttp.HexEncode($objMessage.Body) + "&to=" + `
$objHttp.HexEncode($objMessage.ToAddress))
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
Write-Host $strResponse
...
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
string strResponse = objHttp.Get(
"http://gateway.auronsoftware.com:8080/sendsms/default.asp?" +
"username=CE658B84&password=FAC1982E&text=" +
objHttp.HexEncode(objMessage.Body) + "&to=" +
objHttp.HexEncode(objMessage.ToAddress));
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Console.WriteLine(strResponse);
...
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
strResponse = objHttp.Get( _
"http://gateway.auronsoftware.com:8080/sendsms/default.asp?" & _
"username=CE658B84&password=FAC1982E&text=" & _
objHttp.HexEncode(objMessage.Body) & _
"&to=" & objHttp.HexEncode(objMessage.ToAddress))
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
WScript.Echo strResponse
...
Base64Encode method
Use this method to Base64 encode a string.
Parameters:
- String to encode
Return value:
The encoded string
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$strResponse = $objHttp.Get( `
"http://post.httpprovider.com:8080/sendsms/default.asp?" + `
"username=Name&password=Password&text=" + `
$objHttp.Base64Encode($objMessage.Body) + "&to=" + `
$objHttp.UrlEncode($objMessage.ToAddress))
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
Write-Host $strResponse
...
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
string strResponse = objHttp.Get(
"http://post.httpprovider.com:8080/sendsms/default.asp?" +
"username=Name&password=Password&text=" +
objHttp.Base64Encode(objMessage.Body) + "&to=" +
objHttp.UrlEncode(objMessage.ToAddress));
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Console.WriteLine(strResponse);
...
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
strResponse = objHttp.Get( _
"http://post.httpprovider.com:8080/sendsms/default.asp?" & _
"username=Name&password=Password&text=" & _
objHttp.Base64Encode(objMessage.Body) & _
"&to=" & objHttp.UrlEncode(objMessage.ToAddress))
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
WScript.Echo strResponse
...
Base64EncodeFile method
Use this method to Base64 encode a file.
Parameters:
- The filename of the file to encode
Return value:
The encoded string
Example:
$objHttp = New-Object -ComObject AxSms.Http
$objMessage = New-Object -ComObject AxSms.Message
...
$strResponse = $objHttp.Get( `
"http://post.httpprovider.com:8080/sendsms/default.asp?" + `
"username=Name&password=Password&image=" + `
$objHttp.Base64EncodeFile("logo.png") + "&to=" + `
$objHttp.UrlEncode($objMessage.ToAddress))
if ($objHttp.LastError -ne 0) {
Write-Host "Error: $($objHttp.GetErrorDescription($objHttp.LastError))"
exit 1
}
Write-Host $strResponse
...
var objHttp = new AxSms.Http();
var objMessage = new AxSms.Message();
...
string strResponse = objHttp.Get(
"http://post.httpprovider.com:8080/sendsms/default.asp?" +
"username=Name&password=Password&image=" +
objHttp.Base64EncodeFile("logo.png") + "&to=" +
objHttp.UrlEncode(objMessage.ToAddress));
if (objHttp.LastError != 0)
{
Console.WriteLine($"Error: {objHttp.GetErrorDescription(objHttp.LastError)}");
return;
}
Console.WriteLine(strResponse);
...
Set objHttp = CreateObject("AxSms.Http")
Set objMessage = CreateObject("AxSms.Message")
...
strResponse = objHttp.Get( _
"http://post.httpprovider.com:8080/sendsms/default.asp?" & _
"username=Name&password=Password&image=" & _
objHttp.Base64EncodeFile("logo.png") & _
"&to=" & objHttp.UrlEncode(objMessage.ToAddress))
If objHttp.LastError <> 0 Then
WScript.Echo "Error: " & objHttp.GetErrorDescription(objHttp.LastError)
WScript.Quit 1
End If
WScript.Echo strResponse
...