Created
August 26, 2012 15:56
-
-
Save cloudflying/3481290 to your computer and use it in GitHub Desktop.
Make a Phone call with Twilio
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
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