Archive for December, 2007

BBC Homepage Beta

7

Dec
14

BBC Homepage BetaWell it’s finally happened…  The BBC have released a new version of their now famous homepage in beta and guess what??  They’ve jumped on the Web 2.0 bandwagon.

The home page is fully customisable and even includes some snazzy JavaScript effects.  The page options are editable including font size link colour etc, modules can be dragged and dropped in to your desired position and there is even the option to edit modules on an individual basis allowing you to really see your perfect BBC homepage.  I think one of the biggest points to note is the BBC are using jQuery (which is quite a compliment for the jQuery developers) for their new homepage.

This looks like a step in the right direction for the BBC and could become as popular as iGoogle did for Google.  It will be interesting to see any future enhancements that are made as lets face it the BBC are only just catching up with the times and should really be leading the charge, not lurking in the middle of the pack.

Anyway go and have a look at the BBC Homepage Beta yourself.

Free IP to Location Database

1

Dec
09

I am always looking at ways I can further customise AndrewSellick.com to best meet it’s audience needs and after finding Software 77′s free IP to Location database I knew that I had found another string to my bow.

Software 77 do not only offer a free IP to Location Database, they also offer code free to download enabling you to request their CSV download and import it in to your database.  Further more they offer code (in a multitude of languages) to return the country location of the user making this database extremely easy to use.

The only downside is the lack of regional location data as only country specific IPs are supported.

site

Have a look for yourself at Software 77′s Free IP to Location Database.

code download

View the download page to get your hands on the IP to Location code.

JavaScript Request Querystring Function

1

Dec
09

After searching for some time for a good request querystring solution, for JavaScript, I believe I have finally found it.

Netlobo.com have developed a very useful function that breaks the querystring up into parameters using regular expressions.  This enables you to request the individual parameter you require and with very little added weight on the the load time of the page as the code is only 11 lines in total.

Check ou the JavaScript Request Quesrystring function for yourself.

facebook application development part one

7

Dec
06

Well it’s been a while since I promised a Facebook tutorial and finally it is here. Well Part One at least. :-)
In this first part I will go through the process of creating a very simple Facebook application focusing on the adding the application and the embedded profile application itself.
I will be using PHP5 throughout the course of this tutorial in conjunction with the Facebook PHP5 Client Library.

download the facebook client library 

tutorial

Once you have download the Facebook Client Library and extracted the contents you will be presented with a facebook-platform folder and within this a client folder (The PHP 5 client and the code base we will be using for this tutorial), footprints (A Facebook demo application) and a php4client folder (The PHP 4 client). 

To start off with we will create a folder called “tutorial” within the root “facebook-platform” folder.

Next we need to create to PHP files; index.php and config.inc.php. The contents of these files are displayed below: 

index.php

The index.php provides the foundation for the entire application. This is where the initial add page is created along with the embedded application.

 
  1. First of all we need to include the facebook client library and the config.inc.php.
// the facebook client library
include_once ‘../client/facebook.php’;

// this defines some of your basic setup
include_once ‘config.inc.php’;

  1. Next we instantiate an instance of the facebook class and force the user authentication before logging in.
$facebook = new Facebook($api_key, $secret);
$facebook->require_frame();
$user = $facebook->require_login();
  1. Now we create an add application screen to be initially displayed when a user clicks to see your applications hompage. This code includes two simple facebook variables to display the users facebook username and to add the facebook add url for the application.
<div style="padding: 10px;background-color:#FFFFFF;">
  <h2 style="font-family:arial;font-size:14px;">Hi <fb:name firstnameonly="true" uid="<?=$user?>" useyou="false"/>!</h2><br/>
    
    <div style="width:255px;float:left;border-right:1px solid #FFFFFF;background-color:#333333;height:100px;padding: 10px;"><a href="http://www.andrewsellick.com"><img src="http://news.andrewsellick.com/facebook-platform/asellick/images/logo.gif" alt="AndrewSellick.com" title="AndrewSellick.com" style="border:0px solid #FFFFFF;" /></a></div>
    
    <div style="width:330px;float:left;background-color:#333333;height:70px;color:#FFFFFF;padding: 25px 10px 25px 10px;font-family:arial;">
    
        <p style="margin:0px 0px 8px 0px;">Welcome to the AndrewSellick.com Facebook App.  If you want to know all the latest news on AndrewSellick.com feel free to add this application to your profile.</p>
        <p style="margin:0px 0px 0px 0px;"> <a style="color:#FFFFFF;text-decoration:underline;" href="<?= $facebook->get_add_url() ?>">Add AndrewSellick.com</a>.   &nbsp;&nbsp;&nbsp; Enjoy…</p>
    
    </div>
    
    <div style="clear: both;"/>
    
  <p><a href="<?= $facebook->get_add_url() ?>">Put AndrewSellick.com in your profile</a>, if you haven’t already!</p>
   
  <div style="clear: both;"/>
</div>
  1. Finally we create the FBML code. This is the code that will be displayed for the embedded application. The code is very simple and is added using a Facebook Client API call $facebook->api_client->profile_setFBML(); This set the FBML when the Facebook application is added.
<?php

    // Create the FBML code for the embeded application
    $fbml .= ‘<div style="width:100%;">’;
    $fbml .= ‘<div style="width:133px;float:left;border-right:1px solid #FFFFFF;background-color:#333333;height:100px;padding: 10px;"><a href="http://www.andrewsellick.com"><img src="http://news.andrewsellick.com/facebook-platform/asellick/images/logo-small.gif" alt="AndrewSellick.com" title="AndrewSellick.com" style="border:0px solid #FFFFFF;" /></a></div>’;

    $fbml .= ‘<div style="width:200px;float:left;background-color:#333333;height:100px;color:#FFFFFF;padding: 10px;font-family:arial;font-size:12px;">Welcome to the AndrewSellick.com Facebook App.  This application provides you with the latest news from AndrewSellick.com. <br /><br /><a style="color:#FFFFFF;text-decoration:underline;" href="http://www.andrewsellick.com">Visit AndrewSellick.com</a></div>’;

    $fbml .= ‘<div style="clear: both;"/>’;

    $fbml .= ‘<div style="width:371px; border:1px solid #333333;background-image:url(http://www.andrewsellick.com/wp-content/themes/unsleepable/images/sub-nav-bg.gif);background-repeat:repeat-x;position:top left;" id="andrewsellick-feed">’;
    $fbml .= ‘<div style="padding:10px;font-family:verdana;font-size:11px;">’;
        
            $fbml .= ‘<p style="margin:0px 0px 8px 0px;color:#666666;"><a style="color:#DA1074;" href="http://www.andrewsellick.com/">Link One</a> – </p>’;
            
            $fbml .= ‘<p style="margin:0px 0px 8px 0px;color:#666666;"><a style="color:#DA1074;" href="http://www.andrewsellick.com/">Link Two</a> – </p>’;
            
            $fbml .= ‘<p style="margin:0px 0px 8px 0px;color:#666666;"><a style="color:#DA1074;" href="http://www.andrewsellick.com/">Link Three</a> – </p>’;
            
            $fbml .= ‘<p style="margin:0px 0px 8px 0px;color:#666666;"><a style="color:#DA1074;" href="http://www.andrewsellick.com/">Link Four</a> – </p>’;
            
            $fbml .= ‘<p style="margin:0px 0px 8px 0px;color:#666666;"><a style="color:#DA1074;" href="http://www.andrewsellick.com/">Link Five</a> – </p>’;
        
    $fbml .= ‘</div>’;
$fbml .= ‘</div>’;

$fbml .= ‘<div style="background-color:#333333;width:373px;font-family:arial;font-size:12px;">’;
    $fbml .= ‘<p style="padding:10px;margin:0px;"><a style="color:#FFFFFF;" href="’.$facebook->get_add_url().’">Put AndrewSellick.com in your profile</a></p>’;
$fbml .= ‘</div>’;

$fbml .= ‘</div>’;

$facebook->api_client->profile_setFBML($fbml, $user);

?>

config.inc.php 

In this tutorial the config.inc.php will remain very simple and only includes two variables for the Facebook API key and a secret key. These are provided when you create your Facebook application in within the Facebook developer area (Detailed later in this tutorial).

$api_key = ‘INSERT THE API KEY HERE’;
$secret  = ‘INSERT THE SECRET HERE’;

download the tutorial code 

Download the facebook application development tutorial code.

integrating the application with facebook 

To actually add the application to Facebook you will need to go through the follwing procedures.

 
  1. Upload the code within the facebook-platform folder to a PHP5 hosting environment.
  2. Log in to Facebook and navigate to the Facebook developer page (http://www.facebook.com/developers/).
  3. Click the “Set Up a New Application” button on the top right of the page.
  4. Insert your desired application name and submit.
  5. On setting up the application you will presented with an overview which displays basic application information including the API key and Secret required in your config.inc.php. Copy these two keys and insert them in your config file and then re-upload the file.
  6. Next on the overview page click to edit your newly created application.
  7. Next we need to insert the application details as follows:
    • The Callback Url – Add the URL to the root of the tutorial application folder you created and uploaded as above. I.E. http://www.yourdomain.com/facebook-platfom/tutorial/
    • The Canvas Page URL – Add your desired canvas page URL. This has to be unique to Facebook, although there is automatic validation to prompt you if it is not, so choose wisely. An example could be “andrewsellicktutorial” making the URL http://apps.facebook.com/andrewsellicktutorial/
    • Select the option to allow your application be added on Facebook.
    • The select users to be able to add your application on all pages.
    • Add your Canvas Page URL to the Side Nav URL. I.e. http://apps.facebook.com/andrewsellicktutorial/
    • Now save the application and that’s it.
 

To test it out navigate to the Canvas Page URL in your browser. You should then be able to go through the process of adding the application and finally seeing it displayed on your profile page.

notes 

This is a very basic example so I wouldn’t recommend users start to advertise their applications off the back of this tutorial. There will be more tutorials to come introducing more features and discussions on the Facebook Cache, its potential pitfalls and how to overcome them.

Feel free to play with the code and adapt it for your requirements and let me know how you get on…

I hope this has helped. :-)