I live in Omaha.

Facebook Places Example

by SwervinErv on 09.07.2010

Facebook's Places

With Facebook's introduction of Places, they have given those of us on the interwebs another way digitally to check-in to our favorite venues in the physical world, similar to the likes of Gowalla and Foursquare. Places allows you to let your friends know where you are, as well as check in any friends that may be there with you. There is a bit more to it than that, so if you want some more information on what places is and how it works, you can visit the Facebook Places page.

So why is this relevant? Well to go along with the Places, Facebook has updated their Graph API to allow access to this new feature. For now us basic developers are only able to get information on the checkins, but we should be able to actually perform the checkins and insert data in the near future. A live demo of the application can be found here. So let's get started...

Most of my previous examples have been using the very hand .Net Facebook SDK, but this time around I decided to go with the Facebook Javascript SDK. Since the SDK is pretty simple to get started with, I'll assume you already know where to start and jump right into dealing with the new Places feature of the Graph API. One thing to note is that you will need to pass in the user_checkins extended permission to your login call in order to authorize your application to get your check-in data.

Getting your Check-ins

Using the javascript sdk, we will make a call to the FB.api method, formatting our query like "/{user_id}/checkins". This will make the call to the graph api and return us a list of json objects of your recent checkins including the name of the location and the latitude and longitude that we'll be using in this example. The code for this looks a little someting like this:

// get user's recent checkins
FB.api('/' + uid + '/checkins', function (res) {
    for (var i = 0; i < res.data.length; i++) {
        addMarker(res.data[i].place.location.latitude, 
                  res.data[i].place.location.longitude, 
                  res.data[i].place.name);
    }
}

Once the data has been returned from Facebook, we'll loop through the list of places json objects and then call another method we created, addMarker, which will add our places to an instance of google maps. When running the demo, there is a google maps instance that we will be using to plot our check-ins on to give us some visual reference to where we've been. So, to add a marker to our map, we use the following function:

function addMarker(lat, long, title) {
    var latlng = new google.maps.LatLng(lat, long);
    var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        title: title
    });
}

So that's it. With the Graph API and Javascript SDK from Facebook, it's really simple to go out and grab all of your check-ins.

Code

As always, here is a link to download the full source code for this demo. Enjoy!

Facebook_Places.zip (28.16 kb)



Hello World

by SwervinErv on 01.04.2010

What's going on?

This will be the home for the blog that I am finally starting and have been planning on doing for over a year. Reasons it took this long:

  1. Working for Phenomblue, there always seems to be something more important to work on than my own blog..plus I actually get paid for doing their work..so I have that going for me
  2. I golf quite a bit, more than I should probably mention, and the weather was nice in my neck of the woods this last summer
  3. I have a tendency to not always finish projects, so this is hopefully a step in the right direction
  4. Beer

This isn't where I parked my car...

Hopefully there will be other useful information here, since I don't think I'll be much help finding your car. The plans for this blog include, but are not limited to, cool projects that I have worked on or messed around within the realms of Silverlight, WPF, Microsoft Surface, and javascript to name a few. I also recently upgraded to an HTC Hero that runs Google's Android OS, so hopefully I can find some time to tool around with it, but my Java is a bit rusty.

We deal quite a bit with social media at work, so you can expect mashups galore with the ever growing number of api's (Twitter, Facebook, MySpace, etc...) that are becoming available and can provide some different and unique insights on what really is popular or cool.

What's with the title of the blog?

I'm a golf fanatic, some would say obsessed, and I would kindly agree. The title comes from a quote from the King himself, Arnold Palmer:

"Golf is deceptively simple and endlessly complicated; it satisfies the soul and frustrates the intellect. It is at the same time rewarding and maddening - and it is without a doubt the greatest game mankind has ever invented."

I feel the like the two phrases "deceptively simple" and "endlessly complicated" work very well to describe the world of programming that I work in every day as well as just what life can be in general, and I know from experience that they definitely apply to the game of golf. Plus, you have to figure that a man that has a drink named after him is a pretty smart guy.

Let the games begin

Going forward, I hope there will be hopefully be some informative, maybe entertaining, maybe useless, posts about programming with the possibility of some golf commentary sprinkled in there as well (no Tiger scandal posts, I promise). Oh, and sorry other developers for using the cliché "Hello World" title, my computer wouldn't let me name it anything else since it was my first post...believe me, I tried.