Created
July 31, 2013 16:21
-
-
Save callemall/6123574 to your computer and use it in GitHub Desktop.
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.
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
# ====================================================== | |
# Programming Example on how to check account balance | |
# ====================================================== | |
function CheckAccount | |
( | |
[String] $username, | |
[String] $pin | |
) | |
{ | |
$URL = "http://staging-api.call-em-all.com/webservices/ceaapi_v2.asmx" | |
$Action = "http://call-em-all.com/CheckAccount" | |
[XML] $SOAPRequest = '<?xml version="1.0" encoding="utf-8"?> | |
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> | |
<soap:Body> | |
<CheckAccount xmlns="http://call-em-all.com/"> | |
<myRequest> | |
<username>' + $username +'</username> | |
<pin>' + $pin + '</pin> | |
</myRequest> | |
</CheckAccount> | |
</soap:Body> | |
</soap:Envelope>' | |
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() | |
$SOAPRequest.Save($requestStream) | |
$requestStream.Close() | |
write-host "Send Complete, Waiting For Response." | |
$resp = $soapWebRequest.GetResponse() | |
$responseStream = $resp.GetResponseStream() | |
$soapReader = [System.IO.StreamReader]($responseStream) | |
$ReturnXml = [Xml] $soapReader.ReadToEnd() | |
$responseStream.Close() | |
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