Here the way you can use it
Steps
1. install following nuget packages in project
Google.Apis.Urlshortener.v1
Google.Apis.Urlshortener.v1. Data
Google.Apis.Services
2. Get the API key from following link and paste in “Your API Key”
using System; using Google.Apis.Urlshortener.v1; using Google.Apis.Urlshortener.v1.Data; using Google.Apis.Services; namespace shortenURLwithGoogleAPIService { class Program { private const string ApiKey = "Your API Key"; static void Main(string[] args) { var initializer = new BaseClientService.Initializer { ApiKey = ApiKey, }; var service = new UrlshortenerService(initializer); var longUrl = "your long url"; var response = service.Url.Insert(new Url { LongUrl = longUrl }).Execute(); Console.WriteLine($"Short URL: {response.Id}"); Console.ReadKey(); } } }
Advertisements