Skip to content

Instantly share code, notes, and snippets.

@cloudflying
Created August 26, 2012 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloudflying/3481290 to your computer and use it in GitHub Desktop.
Save cloudflying/3481290 to your computer and use it in GitHub Desktop.
Make a Phone call with Twilio
Imports System.Net
Imports System.Text
Imports System.IO
Public Function makeaCall() as string
Dim AccountSID As String = "aaaaaaa"
Dim authToken As String = "123"
Dim uri As String = "https://api.twilio.com/2010-04-01/Accounts/" & AccountSID & "/Calls"
Dim data As String = "From=+15551234567&To=+15557654321&Url=http://twimlets.com/message?Message[0]=You%20have%20successfully%20called%20me!&Method=POST"
Dim authInfo As String = AccountSID & ":" & authToken
authInfo = Convert.ToBase64String(Encoding.[Default].GetBytes(authInfo))
Dim request As HttpWebRequest = HttpWebRequest.Create(uri)
request.Method = WebRequestMethods.Http.Post
request.ContentLength = data.Length
request.Headers("Authorization") = "Basic " & authInfo
request.ContentType = "application/x-www-form-urlencoded"
Dim writer As New StreamWriter(request.GetRequestStream)
writer.Write(data)
writer.Close()
Dim oResponse As HttpWebResponse = request.GetResponse()
Dim reader As New StreamReader(oResponse.GetResponseStream())
Dim tmp As String = reader.ReadToEnd()
oResponse.Close()
return tmp
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment