Skip to content

Nexmo/nexmo-dotnet-code-snippets

 
 

Repository files navigation

Nexmo APIs code snippets for .NET using CSharp

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.

Configure with Your Nexmo Credentials

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.

TLS Upgrade

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;

Request an Example

Please raise an issue to request an example that isn't present within the code snippets. Pull requests will be gratefully received.

License

This code is licensed under the MIT license.

About

.NET code samples for using Nexmo

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 95.9%
  • HTML 2.9%
  • Other 1.2%