作为参考,下面是我尝试在dart/flutter中复制的CURL命令。
curl https://example.signalwire.com/api/laml/2010-04-01/Accounts/{AccountSid}/Messages.json \
-X POST \
--data-urlencode "From=+15551234567" \
--data-urlencode "Body=Hello World\!" \
--data-urlencode "To=+15557654321" \
-u "YourProjectID:YourAuthToken"发布于 2020-06-21 08:03:49
import 'dart:convert';
import 'package:http/http.dart' as http;
String accountSid = '12345';
String yourAuthToken = '12345';
String yourProjectID = '12345';
String from = '15551234567';
String body = 'Hello World!'
String to = '15557654321'!
String url = 'https://example.signalwire.com/api/laml/2010-04-01/Accounts/$accountSid/Messages.json';
Map<String, String> headers = <String, String>{
yourProjectID: yourAuthToken,
};
String body = jsonEncode(<String, dynamic>{
'From': from,
'Body':
'Hello World\!', 'To': '+15557654321'
});
http.Response response = await http.post(url, body: body, headers: headers); https://stackoverflow.com/questions/62492505
复制相似问题