Skip to content

Instantly share code, notes, and snippets.

@ealvesss
Created August 15, 2022 21:36
Show Gist options
  • Save ealvesss/1444ba6bda233f9ab907ef814cf7aa92 to your computer and use it in GitHub Desktop.
Save ealvesss/1444ba6bda233f9ab907ef814cf7aa92 to your computer and use it in GitHub Desktop.
chat-twilio
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