Tim Hibbard

Software Architect for EnGraph software
posts - 615, comments - 677, trackbacks - 469

My Links

News



Add to Google




Twitter












Tag Cloud

Article Categories

Archives

Post Categories

Image Galleries

EnGraph Blogs

Links

Other

Roll

Getting BrightKite friends using C# and LINQ

BrightKite is a location aware social network.  It allows you to post notes and pictures at a specific place.  It also will write to your Twitter stream so your friends can keep up with your latest activity.

They also have an API, which I had the chance to play with the other night.  Here is some very simple code that will write out a list of all your friends:

        public static void ListFriends(string username, string password)
        {
            string url = "http://brightkite.com/me/friends.xml";
            WebRequest WRequest = WebRequest.Create(url) as HttpWebRequest;
            WRequest.Timeout = 10000;
            WRequest.Headers.Add("Authorization", 
                "Basic " + Convert.ToBase64String(
                Encoding.ASCII.GetBytes(username + ":" + password)));
 
            using (HttpWebResponse response = WRequest.GetResponse() as HttpWebResponse)
            {
                StreamReader reader = new StreamReader(response.GetResponseStream());
                XElement element = XElement.Load(reader);
                foreach (XElement node in element.Elements("person"))
                {
                    string place = node.Element("place").Element("name").Value;
                    string person = node.Element("fullname").Value;
                    
                    Console.WriteLine("{0} checked in at {1}",person,place);
                }
            }
        }

My BrightKite = timhibbard
My Twitter = timhibbard



Print | posted on Monday, November 10, 2008 2:19 PM | Filed Under [ .NET Social Geocoding ]

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 

Powered by: