Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This example uses the CheckAccount function to retrieve some basic information and settings on an account including its status, the available call balance, and most of the settings seen on the "My Account" tab when logged in to a Call-Em-All account.
# ======================================================
# Programming Example on how to check account balance
# ======================================================
function CheckAccount
[String] $username,
[String] $pin
$URL = ""
$Action = ""
[XML] $SOAPRequest = '<?xml version="1.0" encoding="utf-8"?>
&lt;soap:Envelope xmlns:xsi="" xmlns:xsd="" xmlns:soap=""&gt;
&lt;CheckAccount xmlns=""&gt;
&lt;username&gt;' + $username +'&lt;/username&gt;
&lt;pin&gt;' + $pin + '&lt;/pin&gt;
write-host "Sending SOAP Request To Server: $URL"
write-host "SOAP Request : " + $SOAPRequest
$soapWebRequest = [System.Net.WebRequest]::Create($URL)
$soapWebRequest.Headers.Add("SOAPAction", $Action)
$soapWebRequest.ContentType = "text/xml;charset=`"utf-8`""
$soapWebRequest.Accept = "text/xml"
$soapWebRequest.Method = "POST"
write-host "Initiating Send."
$requestStream = $soapWebRequest.GetRequestStream()
write-host "Send Complete, Waiting For Response."
$resp = $soapWebRequest.GetResponse()
$responseStream = $resp.GetResponseStream()
$soapReader = [System.IO.StreamReader]($responseStream)
$ReturnXml = [Xml] $soapReader.ReadToEnd()
write-host "============================================"
write-host "errorCode " $ReturnXml.Envelope.Body.CheckAccountResponse.CheckAccountResult.errorCode
write-host "errorMessage " $ReturnXml.Envelope.Body.CheckAccountResponse.CheckAccountResult.errorMessage
write-host "Call Balance " $ReturnXml.Envelope.Body.CheckAccountResponse.CheckAccountResult.CallBalance
write-host "CallerID " $ReturnXml.Envelope.Body.CheckAccountResponse.CheckAccountResult.CallerID
write-host "============================================"
return [xml] $ReturnXml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.