Skip to content

netdragoon/shorturl

Repository files navigation

ShortUrl

Canducci ShortUrl

Build status NuGet NuGet

The package offers providers in their most current version can be selected for obtaining URL shortened. Are they:

All of these providers work in a clear and objective manner to generate the urls.

####Nuget installation

PM> Install-Package CanducciShortUrl

####How to use:

Declare o namespace using Canducci.ShortUrl;

####Code:

The only difference now is that first of all must choose each providers offered for the SHORTURL make the obtaining of the information operations. It will be shown each logo below:

To work to make the registration on the site and get your token, given primary for funcionalmento by that provider.

string url = "http://www.nuget.org";
string token = "token";
Bitly provider = new Bitly(token, url);
ShortUrlClient client = ShortUrlClientFactory.Create(provider);
ShortUrlReceive receive = client.Receive();

Example: Create a username and password and get your token.

Bitly


Googl (https://developers.google.com/url-shortener/v1/getting_started)

To work to make the registration on the site and get your key, given paramount to funcionalmento by that provider.

string url = "http://www.nuget.org";
string key = "key";
Googl provider = new Googl(key, url);
ShortUrlClient client = ShortUrlClientFactory.Create(provider);
ShortUrlReceive receive = client.Receive();

Example: Create a username and password. Link to more information: (https://support.google.com/cloud/answer/6158862?hl=en&ref_topic=6262490)


IsGd (http://is.gd)

No configuration package through immediate availability of information.

string url = "http://www.nuget.org";
IsGd provider = new IsGd(url);
ShortUrlClient client = ShortUrlClientFactory.Create(provider);
ShortUrlReceive receive = client.Receive();

MigreMe (http://migre.me/)

No configuration package through immediate availability of information.

string url = "http://www.nuget.org";
MigreMe provider = new MigreMe(url);
ShortUrlClient client = ShortUrlClientFactory.Create(provider);
ShortUrlReceive receive = client.Receive();

TinyUrl (http://tinyurl.com/)

No configuration package through immediate availability of information.

string url = "http://www.nuget.org";
TinyUrl provider = new TinyUrl(url);
ShortUrlClient client = ShortUrlClientFactory.Create(provider);
ShortUrlReceive receive = client.Receive();

TrIm (https://tr.im/links)

To work to make the registration on the site and get your key, given paramount to funcionalmento by that provider.

string url = "http://www.nuget.org";
string key = "key";
TrIm provider = new TrIm(key, url);
ShortUrlClient client = ShortUrlClientFactory.Create(provider);
ShortUrlReceive receive = client.Receive();

Example: Create a username and password on tr.im site. After entering the site go to Settings and ApiKey guide:

####Settings

Settings 1

####ApiKey

Settings 2

The ApiKey your account tr.im site is responsible for the integration with the code, as in the example below the variable string ApiKey and variable string url any valid internet address.


The providers TinyUrl, MigreMe e IsGd do not need any related token or key settings are simpler and just need the url to generate a short url.


####Facade

Can be used the facade also this:

Googl googl = new Googl("key", "http://www.nuget.com");
ShortUrlFacade facade = new ShortUrlFacade(googl);
ShortUrlReceive receive = facade.Receive();

####Example MVC ASP.NET

[HttpPost()]
public async Task<JsonResult> GetBitLy(string url)
{
    string token = "token";
    Bitly provider = new Bitly(token, url);
    ShortUrlClient client = ShortUrlClientFactory.Create(provider);            
    return Json(await client.ReceiveAsync(), JsonRequestBehavior.DenyGet);
}

[HttpPost()]
public async Task<JsonResult> GetGoogl(string url)
{
    string key = "key";
    Googl provider = new Googl(key, url);
    ShortUrlClient client = ShortUrlClientFactory.Create(provider);
    return Json(await client.ReceiveAsync(), JsonRequestBehavior.DenyGet);
}

[HttpPost()]
public async Task<JsonResult> GetIsGd(string url)
{
    IsGd provider = new IsGd(url);
    ShortUrlClient client = ShortUrlClientFactory.Create(provider);
    return Json(await client.ReceiveAsync(), JsonRequestBehavior.DenyGet);
}

[HttpPost()]
public async Task<JsonResult> GetMigreMe(string url)
{            
    MigreMe provider = new MigreMe(url);
    ShortUrlClient client = ShortUrlClientFactory.Create(provider);
    return Json(await client.ReceiveAsync(), JsonRequestBehavior.DenyGet);
}

[HttpPost()]
public async Task<JsonResult> GetTinyUrl(string url)
{            
    TinyUrl provider = new TinyUrl(url);
    ShortUrlClient client = ShortUrlClientFactory.Create(provider);
    return Json(await client.ReceiveAsync(), JsonRequestBehavior.DenyGet);
}

[HttpPost()]
public async Task<JsonResult> GetTrIm(string url)
{
    string key = "key";
    TrIm provider = new TrIm(key, url);
    ShortUrlClient client = ShortUrlClientFactory.Create(provider);
    return Json(await client.ReceiveAsync(), JsonRequestBehavior.DenyGet);
}

Note:

  • remember that the async methods (ReceiveAsync) are present as the .NET Framework version (> = 4.5).

####Old Version

The old version only works with trim and are in that link your settings (https://github.com/netdragoon/shorturl/blob/master/README001002.md)