The purpose of the code snippets project is to provide simple examples focused on one goal. For example, sending an SMS, handling an incoming SMS webhook or making a Text to Speech call.
To use this sample you will first need a Nexmo account. Once you have your own API credentials, Create a Nexmo Client instance and pass in credentials in the constructor.
var client = new Client(creds: new Nexmo.Api.Request.Credentials
{
ApiKey = "NEXMO-API-KEY",
ApiSecret = "NEXMO-API-SECRET"
});Alternatively, provide the nexmo URLs, API key, secret, and application credentials (for JWT) in appsettings.json:
{
"appSettings": {
"Nexmo.UserAgent": "myApp/1.0",
"Nexmo.Url.Rest": "https://rest.nexmo.com",
"Nexmo.Url.Api": "https://api.nexmo.com",
"Nexmo.api_key": "NEXMO-API-KEY",
"Nexmo.api_secret": "NEXMO-API-SECRET",
"Nexmo.Application.Id": "ffffffff-ffff-ffff-ffff-ffffffffffff",
"Nexmo.Application.Key": "c:\\path\\to\\your\\application\\private.key"
}
}For some of the examples, you will need to buy a number.
Nexmo permanently disabled support of legacy TLSv1 and TLSv1.1 protocols. Vulnerabilities within these TLS versions are serious and, left unaddressed, put organizations at risk of being breached. The only supported encryption protocol for HTTPS connections is now TLSv1.2. All API requests and all web requests to the Nexmo Dashboard using legacy TLS protocols will be rejected.
In case you are still using a legacy TLS protocol, make sure to force your app to TLSv1.2 by adding this line of code :
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;Please raise an issue to request an example that isn't present within the code snippets. Pull requests will be gratefully received.
This code is licensed under the MIT license.