Created
August 15, 2022 21:36
-
-
Save ealvesss/1444ba6bda233f9ab907ef814cf7aa92 to your computer and use it in GitHub Desktop.
chat-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
Future<void> sendMessage({required String accountSid, required String authToken, required String sidConversation, required String message})async{ | |
var cred = '$accountSid:$authToken'; | |
var bytes = utf8.encode(cred); | |
var base64Str = base64.encode(bytes); | |
String url = 'https://conversations.twilio.com/v1/Conversations/CH1007ef70dfbb43b0a4fbb84d5484cb64/Messages'; | |
var response = await http.post(Uri.parse(url), | |
headers: { | |
'Accept': '*/*', | |
'Content-Type': 'application/x-www-form-urlencoded', | |
'Authorization': '<user>:<password>' | |
}, | |
body: {'Body':'flutter request test','Author':'Bjørn'} | |
); | |
print(response.statusCode); | |
print(response.body); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment