Skip to content

A Bitly API Wrapper service that uses OAuth 2.0 authentication and T4 templates to make adding new endpoints easy.

Notifications You must be signed in to change notification settings

levelnis/openbitly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open Bitly

A Bitly API Wrapper service that uses OAuth 2.0 authentication and T4 templates to make adding new endpoints easy.

Massive kudos to Daniel Crenna and Tweetsharp, upon which most of this was based.

Usage

Here's a quick example of shortening a URL using Open Bitly within a class named LinkService:

  • Inject an instance of IBitlyService and IBitlyOptionFactory into LinkService

  • Instantiate a ShortenUrlOptions object with the long url

  • Pass the ShortenUrlOptions to the service

  • Return the short url from the response

      public LinkService(IBitlyService bitlyService, IBitlyOptionFactory bitlyOptionFactory)
      {
        this.bitlyService = bitlyService;
        this.bitlyOptionFactory = bitlyOptionFactory;
      }
    
      public string ShortenUrl(string fullUrl)
      {
        var options = bitlyOptionFactory.CreateShortenUrlOptions(HttpUtility.UrlEncode(fullUrl));
        var response = bitlyService.ShortenUrl(options);
        return response.Data.Url;
      }
      

About

A Bitly API Wrapper service that uses OAuth 2.0 authentication and T4 templates to make adding new endpoints easy.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published