Thursday 7 November 2013

Twilio REST API with Powershell

Twilio empowers developers to build powerful communication. Twilio powers the future of business communications, enabling phones, VoIP, and messaging to be embedded into web, desktop, and mobile software. We take care of the messy telecom hardware and expose a globally available cloud API that developers can interact with to build intelligent & complex communications systems.

Twilio has a truly great communication API, but sadly no Powershell examples on how to use it. So, here is a quick example on how to call the REST API to initiate a phone call.

$password = ConvertTo-SecureString "<AuthKey>" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential ("<AccountSid>", $password )
$body = "Url=http://your_server/api/twilio&To=<Number>&From=<Number>"
Invoke-RestMethod "https://api.twilio.com/2010-04-01/Accounts/<AccountSid>/Calls.json" -Body $body -Credential $credential -Method "POST" -ContentType "application/x-www-form-urlencoded"

No comments:

Post a Comment