Shorten() public method

For a long URL, /v3/shorten encodes a URL and returns a short one. http://code.google.com/p/bitly-api/wiki/ApiDocumentation#/v3/shorten
public Shorten ( string longUrl, string domain = null, string xLogin = null, string xApiKey = null ) : IBitlyResponse
longUrl string is a long URL to be shortened (example: http://betaworks.com/)
domain string refers to a preferred domain; either bit.ly default or j.mp. This affects the output value of url
xLogin string is the end-user's login when make requests on behalf of another bit.ly user. This allows application developers to pass along an end user's bit.ly login
xApiKey string is the end-user's apiKey when making requests on behalf of another bit.ly user. This allows application developers to pass along an end user's bit.ly apiKey
return IBitlyResponse
Example #1
0
 public string Shorten(string url)
 {
     var bitly = new BitLyProvider(login, apiKey);
     var result = bitly.Shorten(url);
     if (result.Data == null)
     {
         throw new Exception(result.StatusTxt);
     }
     return result.Data.Url;
 }
Example #2
0
        public static string Encrypt(string input)
        {
            var bitly = new BitLyProvider("monkieboy", "R_b36be051b416a3797b8f3c67526b872f");
            var shortened = bitly.Shorten(input);
            input = shortened.Data.Url;
            var bareCode = input.Replace("http://bit.ly/", string.Empty);

            string encodedBareCode = Encode(bareCode);

            return encodedBareCode;
        }