Wednesday, March 18, 2009

Bit.ly C# API Update

I decided to update my Bit.ly API DLL in C#, thanks to @codemypantsoff. The only new function that I added was the ability to get the User who shortened a URL from the Short URL or from the Hash. I figured it was also a good time to move all my stuff from my Google Sites page onto a blog post, so here it goes.

 Calls:

MetaH - Retrieves the metadata from a hash

string a = API.Bit("bitlyapidemo", "R_0da49e0a9118ff35f52f629d2d71bf07", "epicdiggnation", "MetaH");
Console.WriteLine(a);

MetaU - Retrieves the metadata from a Short Url

string b = API.Bit("bitlyapidemo", "R_0da49e0a9118ff35f52f629d2d71bf07", "http://bit.ly/1RmnUT", "MetaU");
Console.WriteLine(b);

ExpandH - Returns the Expanded url from a hash

string c = API.Bit("bitlyapidemo", "R_0da49e0a9118ff35f52f629d2d71bf07", "epicdiggnation", "ExpandH");
Console.WriteLine(c);

ExpandU - Returns the Expanded url from a Short Url

string d = API.Bit("bitlyapidemo", "R_0da49e0a9118ff35f52f629d2d71bf07", "http://bit.ly/1RmnUT", "ExpandU");
Console.WriteLine(d);

Shorten - Returns a Shortened URL from a long URL
string e = API.Bit("bitlyapidemo", "R_0da49e0a9118ff35f52f629d2d71bf07", "http://cnn.com", "Shorten");
Console.WriteLine(e);

ClicksH - Returns number of clicks from a hash

string f = API.Bit("bitlyapidemo", "R_0da49e0a9118ff35f52f629d2d71bf07", "epicdiggnation", "ClicksH");
Console.WriteLine(f);

ClicksU - Returns number of clicks from a Short Url

string g = API.Bit("bitlyapidemo", "R_0da49e0a9118ff35f52f629d2d71bf07", "http://bit.ly/1RmnUT", "ClicksU");
Console.WriteLine(g);

UserU - Returns the User who shortened the URL from a Short Url

string h = API.Bit("bitlyapidemo", "R_0da49e0a9118ff35f52f629d2d71bf07", "http://bit.ly/1RmnUT", "UserU");
Console.WriteLine(h);

UserH - Returns the User who shortened the URL from a Hash

string i = API.Bit("bitlyapidemo", "R_0da49e0a9118ff35f52f629d2d71bf07", "epicdiggnation", "UserH");
Console.WriteLine(i);


Console Application sample code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bitly;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = API.Bit("bitlyapidemo", "R_0da49e0a9118ff35f52f629d2d71bf07", "http://cnn.com", "Shorten");
            Console.WriteLine(a);
            Console.Read();
        }
    }
}

DLL Link
Source Link

If anyone would like me to update my WPF sample app or has a feature request, go ahead and contact me.

1 comments:

Dylan Barber said...

cool i am looking at that now - one thing I am trying to work with is there is a http://bit.ly/app/demos/info.html notice the twitternames that had used that link - wondering if you could expose that - if not i'll do it just you are more familiar with your code

Post a Comment