Tag Archives: api

No Such Thing as a Free Lunch

So Twitter has cause a mini storm by turning on its developer ecosystem. Anyone who didn’t see this coming have been very naive. Any business who utilises a third-party system such as the APIs/Platforms/Marketplaces in order to make money doesn’t have a business built on solid foundations.

Sure you can argue that it is the developers who have made Twitter or Facebook or Apple or ANother service popular but at the end of the day these are the companies who hold all the cards. They are free to change their terms and conditions as they see fit. People may call foul but ultimately these companies are here to make money and they will do so as they please. The only way around this is to be the company holding the cards.

Would I still develop a Facebook App for a client, or an iOS app etc. You bet I would, but if it was for me my eyes are open, if it is for a client then I would have a duty to open their eyes as well. Don’t like this then vote with your feet, don’t utilise this platform, or except the risks. Beware the third-party, especially if the service is “free”.

Twitter’s Tweet Button

Hot on the heals of Facebook’s Like buttons Twitter today announced a button of their on to place on your site. Tweet buttons are nothing new and Tweetmeme has had one available for a long time. It looks as though Twitter has been working closely with Tweetmeme on their implementation although I am not currently aware of there being any news that Tweetmeme has been aquired by Twitter.

As simple to use as the Facebook Social Plug-ins you simple visit the tweetbutton page choose your options and you are presented with a code to cut and paste into your site.

There are a number of options available, the most interesting is the ability to specify multiple accounts (up to two) which you can follow after using the button. This is particularly useful for sites run by multiple contributors presenting options to follow the person who wrote the an article as well as the main site twitter feed. There is also a developer API where you can roll your own code for the button and tweak to your specific needs.

As usual with these easy share options I’ve given it a go on my site. I’ve copied and pasted the code into the post page and placed it with my Facebook Like buttons. In doing this I’ve also removed my @anywhere tweet box which didn’t seem as useful.

Facebook Open Graph

Now that the initial rush revolving around adding “Like” buttons to a site has died down a bit I’ve decided to revisit it a bit. Of course having spent a little more time researching and reading the docs it seems my initial implementation was a little off, well not for adding the like button but in terms of the wider Open Graph protocol. If you want to share in the Open Graph goodness there’s a bit more that you need to do to your site, I for one believe these extra steps are worth doing, especially if you look at it taking into account the direction Facebook seems to be taking, more on that later.

First whats wrong with my original implementation? Well in terms of showing the “Like” button there was nothing wrong, but being the curious little bee I am I want looking to see if I could find information on who had “Liked” my page. My understanding was that if you know the ID of the object which is being “liked” then you can find out more about it using the Facebook Open Graph API but how do you find out the ID of your site that has the “Like” button on it?

My first attempt was to fire up Firebug and inspect the “Like” button code to see if the ID was contained within. Not much luck there I’m afraid. I then had a thought why not use the Open Graph itself to find out the ID, I “Liked” the page so surely I could use myself as the starting point and see what I liked to get the the ID of the page. Using the URL: https://graph.facebook.com/me/likes returned me a JSON object like this:

{
   "data": [
      {
         "name": "Billy Joel",
         "category": "Musicians",
         "id": "57084011597"
      },
      {
         "name": "Muse",
         "category": "Musicians",
         "id": "8762738724"
      },
...
   ]
}

Unfortunately my site wasn’t in this list, it wasn’t part of the Open Graph. At this point I obviously suspected something was wrong and did what any good developer should have done from the start and read the documentation. Having the “like” button on the page isn’t enough to satisfy being in the Open Graph you also need to add meta data to the page for it to show up. Fortunately this is pretty easy (as always) in wordpress. Edit the template file header.php and add the following lines:

<?php if ( is_single() ): ?>
  <meta property="og:title" content="<?php wp_title('',true, 'right'); ?>"/>
  <meta property="og:type" content="article"/>
  <meta property="og:url" content="<?php the_permalink();?>"/>
<?php else : ?>
  <meta property="og:title" content="Al Binns' Web Stuff"/>
  <meta property="og:type" content="blog"/>
  <meta property="og:url" content="http://www.albinns.com"/>
  <meta property="og:description"
          content="Welcome to the personal blog of Al Binns. This blog is my 
                   playground on all things web related. The views expressed 
                   here are soley mine and do not represent the views of my 
                   employer."/>
<?php endif; ?>
<meta property="og:image" content="<?php bloginfo('template_directory'); ?>/images/fb-image.png"/>
<meta property="fb:admins" content="685696835"/>
<meta property="og:site_name" content="Al Binns' Web Stuff"/>

Adding this meta data and then clicking the “Like” button adds the following entry to my likes JSON Object, my blog is now in there:

{
   "data": [
...
      {
         "name": "Al Binns' Web Stuff",
         "category": "Personal blog",
         "id": "138016126225295"
      },
...
   ]
}

I now had the information I was looking for and a whole lot more as well. Using the Open Graph in this way also created a page on Facebook for my site with all the bells and whistles that go with it. My site is effectively part of the Facebook eco-system, check out the page here: http://www.facebook.com/pages/Al-Binns-Web-Stuff/138016126225295

This brings me back to the importance Facebook is placing on the Open Graph. Not only are they mapping multitudes of objects and their relationships from the real world they are also changing the way some of their internal functions work to reflect this. I noticed today that if you go into your profile and had previously entered certain profile information – education and work experience for example – the information was no longer valid. They now map things like this based on pages on the site, which in turn are all objects in the Open Graph. To fundamentally change how the profile system works for 400 million people shows how much weight Facebook are throwing behind the Open Graph and I suspect they have only just begun tapping the potential of this.

The good things is that it is based on an open system and is not proprietry, as other systems also embrace this the possibilities are staggering. As for how I’ll be using it we will have to wait and see. Currently my graph is small but you can change this by liking my stuff!

It’s F8 Dude

Following on from last weeks round up from Chirp is this weeks round up from F8 Facebook’s equivalent conference which took place this week. Just like Twitter, Facebook had a number of interesting announcements for developers, here’s a quick summary. Also not to be outdone by Twitter I’ve also taken a closer look at one of the announcements and intergrated it into my blog, more on that later.

Open Graph Protocol

Facebook’s Open Graph protocol allows you to easily integrate your site into the social space. Your web page like many out there can easily be classified as a type. Using these types Facebook aims to establish connections between you, your friends and these types. The example they have used is IMDb and how by specially marking up the pages to help describe them in terms of objects (in this case of the movie type), their users can then associate themselves with the page. This is achieved through a “like” mechanism which basically says “hey I like this movie”. This information will be able to be used in any number of ways – instant recommendation engines from people you trust!

Right now there is a limited set of object types but even if your site doesn’t have content which falls into one of these types you can always default back to the type “website” which effectively any page can be part of.

Graph API

Alongside the Open Graph is a Graph API to let you tap into this data. It will allow you to both read and write data into and out of Facebook. This is rather significant as previously Facebook has been a bit of a walled garden, all data contained within it was not accessible. This changed a bit with the use of Facebook Connect, this has now been pushed even further with an API to access this data. As all data is connected to each other and back to you it provides with a potentially very powerful tool. For example if you wanted to find out the films your friends like Facebook will give you an opportunity to do this.

oAuth 2.0

Privacy of course is a hot topic where Facebook is concerned. People should not be able to access all this data by default. When FB added Facebook Connect as a way of accessing Facebook on your own websites this was a proprietry system, and in my experience not an easy one to implement. At F8 Facebook announced it will be using oAuth 2.0 to replace FB connect. This allows people to autheticate your applications against Facebook giving the user control as to whether you can access the data you are feeding into Facebook. oAuth 2.0 is an excellent protocol and very easy to use. It should simplify using Facebook Connect considerably.

Social Plugins

Not the last thing at the conference by any means but the last thing I want to mention are the Social Plugins. These are a number of plug-ins which allow you direct access to public information directly on your website. The important point here, for any privacy zealots out there, is that this is public information, you have full control over your data in Facebook, OK the default is public but my mantra is usually if you don’t want things on the web don’t put them there, especially in the hands of a third party company.

These plug-ins are quite frankly excellent, they will give users instant personalisation on a website, allow you to quickly add information to your profile (or social graph) and will be ubiquitous across the web in weeks, if not days. I’ve used the “Like Button” plug-in both on the Homepage of this blog and at the bottom of each individual post. Configuring the plug-in was as simple as chaging a few options and cutting and pasting the resultant code into my blog template.

Summary

Overall I think Facebook have made huge strides in opening up their data. Don’t get me wrong they’ve done it for their own selfish reasons but the Social Graph will be one of the next big things and 400 (500?) million users will makes its adoption a hell of a lot quicker than starting from scratch. I’m interested to see what comes out of this over the coming months, mashups a plenty! No doubt we’ll get to work hands on with all these new tools in the near future.