<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>CanalPlan Blogs Posts</title>
	
	<link>http://blogs.canalplan.org.uk</link>
	<description>The home of Blogs for CanalPlan</description>
	<pubDate>Tue, 27 Jul 2010 10:09:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<language>en</language>
    			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CanalplanBlogsMasterSiteFeed" /><feedburner:info uri="canalplanblogsmastersitefeed" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
				<title>Still Alive</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/j91Dhku9u7k/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2010/07/27/still-alive-2/#comments</comments>
				<pubDate>Tue, 27 Jul 2010 10:09:06 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2010/07/27/still-alive-2/</guid>
                <description><![CDATA[I know its been pretty quiet round here for a bit. Its just been one of those periods of time when I'd nothing really to write about, and even if I did I didn't really have the time, or the motivation, or the energy.

When I've not been working I've been bashing my head against the wall over my <a href="http://wordpress.org/extend/plugins/wordbooker/">Wordbooker</a> plugin which I've been playing a continual catch up game with Facebook and Wordpress and W3C compliance (some of which was nothing to do with me but actually Facebook's decision to use non compliant tags and people having Wordpress themes with not quite the right Doctypes and other things). I've been wanting for ages to start on Version 2 of the plugin - which takes a different approach to parts of the posting process and needs a complete re-write of the comment handling process too, but until I'd got the 1.x code base to the point that it was stable enough to leave alone so I could concentrate on 2.0 I couldn't do that.  I'd just got ready to start recoding when Facebook announced they were changing the method of authenticating users against applications... that's right. Just a couple of months after they changed it totally they are proposing changing it all again. It didn't help that they accidentally turned on the new method and broke everything! 

But things seem to have settled down and so I've started coding it, but I also wanted to watch "Travelling Man" which Nick had bought me on DVD for my birthday after we'd both read <a href="http://www.grannybuttons.com/granny_buttons/2010/05/travelling-man---bashes-to-splashes.html">Andrew Denny's blog entry</a> about it. It's been quite enjoyable watching it and recognising a lot of the locations, even if they have changed a lot since it was shot : for example the derelict warehouses near Preston Brook have been turned in to rather up market apartments - but it was good to see that <a href="http://www.claymoore.co.uk/">Claymore Navigation's</a> boatyard hasn't changed much in the intervening years.

So today I'm having a day off work, and I could be coding but instead I'm listening to Bob Geldof's solo albums and trying to rustle up enough motivation to do much more than slouch on the sofa all day. I know that some would say that NOT listening to them would be enough motivation to get off the sofa, and others might say that listening to them just sucks motivation away from you, but hey... it's my day off and I'm waiting for the Dishwasher to go through a cleaning cycle! 

]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/IYWQvs77QNa-SMufTquMzmX8IEc/0/da"><img src="http://feedads.g.doubleclick.net/~a/IYWQvs77QNa-SMufTquMzmX8IEc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/IYWQvs77QNa-SMufTquMzmX8IEc/1/da"><img src="http://feedads.g.doubleclick.net/~a/IYWQvs77QNa-SMufTquMzmX8IEc/1/di" border="0" ismap="true"></img></a></p>I know its been pretty quiet round here for a bit. Its just been one of those periods of time when I'd nothing really to write about, and even if I did I didn't really have the time, or the motivation, or the energy.

When I've not been working I've been bashing my head against the wall over my <a href="http://wordpress.org/extend/plugins/wordbooker/">Wordbooker</a> plugin which I've been playing a continual catch up game with Facebook and Wordpress and W3C compliance (some of which was nothing to do with me but actually Facebook's decision to use non compliant tags and people having Wordpress themes with not quite the right Doctypes and other things). I've been wanting for ages to start on Version 2 of the plugin - which takes a different approach to parts of the posting process and needs a complete re-write of the comment handling process too, but until I'd got the 1.x code base to the point that it was stable enough to leave alone so I could concentrate on 2.0 I couldn't do that.  I'd just got ready to start recoding when Facebook announced they were changing the method of authenticating users against applications... that's right. Just a couple of months after they changed it totally they are proposing changing it all again. It didn't help that they accidentally turned on the new method and broke everything! 

But things seem to have settled down and so I've started coding it, but I also wanted to watch "Travelling Man" which Nick had bought me on DVD for my birthday after we'd both read <a href="http://www.grannybuttons.com/granny_buttons/2010/05/travelling-man---bashes-to-splashes.html">Andrew Denny's blog entry</a> about it. It's been quite enjoyable watching it and recognising a lot of the locations, even if they have changed a lot since it was shot : for example the derelict warehouses near Preston Brook have been turned in to rather up market apartments - but it was good to see that <a href="http://www.claymoore.co.uk/">Claymore Navigation's</a> boatyard hasn't changed much in the intervening years.

So today I'm having a day off work, and I could be coding but instead I'm listening to Bob Geldof's solo albums and trying to rustle up enough motivation to do much more than slouch on the sofa all day. I know that some would say that NOT listening to them would be enough motivation to get off the sofa, and others might say that listening to them just sucks motivation away from you, but hey... it's my day off and I'm waiting for the Dishwasher to go through a cleaning cycle! 

<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/j91Dhku9u7k" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2010/07/27/still-alive-2/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2010/07/27/still-alive-2/</feedburner:origLink></item>
						<item>
				<title>Revisiting "old" Code</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/esiF0NdprYI/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2010/05/19/revisiting-old-code/#comments</comments>
				<pubDate>Wed, 19 May 2010 14:23:21 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2010/05/19/revisiting-old-code/</guid>
                <description><![CDATA[Nick commented once about some of the code in <a href="http://www.canalplan.org.uk/">CanalPlan AC </a>and how it was suffering from "bit rot". Basically code that you shoved in, often as a quick dirty fix and  then it starts to fail but with no good reason.

Well <a href="http://wordpress.org/extend/plugins/wordbooker/">Wordbooker</a> is suffering from bit rot, its just that luckily no-one has noticed it yet, well apart from me that is.

Wordbooker took code written by Robert Tsai for his plugin (Wordbook) and extended it. That is why Wordbooker is called Wordbooker - because it stands for WordbookE[xtended]R[elease].  Robert's code used to support the Wordpress PHP libraries for PHP4 and PHP5. PHP4 support was dropped but the wrappers were left inside the code, adding a level of abstraction around the calls to the Facebook PHP libraries.

When I added all the new features such as posting to walls and FB widgets and so on, into his code I sometimes used his wrappers and sometimes made the calls directly.  

Facebook then depreciated some functionality and so calls to functions supporting that got commented out and eventually I stripped most of the code out.

I'd added functionality to handle comments really as a sort of proof of concept and then I added posting support to pages, but comments to pages didn't get processed properly due to slight differences inside FB on how pages are handled.

So that was the next big project - re-write comment handling to make it a lot more robust (and at the same time simpler). 

But then Facebook came along with the Graph API and the Oauth authentication process and said that all applications would be force migrated to the new Authentication method on June 1st.  The new Graph API would make my job simpler as I only use a few calls (post to wall, post comment, get comment, get status, and a few FQL calls) and so obviously I should think about moving my code to use it.

That wouldn't be bad if the Graph API was complete and not riddled with bugs (for example if you include a link in a post it thinks you are doing a "share" style post and goes and scrapes that URL - something which is not right and not how the old API works),  but as it is I can't use the new API for anything but authentication, so I've had to work out how to use the Oauth method for signing on, but then use the old API for the rest of my code, all under the looming date of the end of the month and with me working a day job as well.

Facebook also changed their policy on posting to walls and I asked them for clarification, and they asked for more information which I've given them, and now I'm waiting to hear back from them. It could mean that I have to change my code, but actually it will make the process easier to code and make it easier for the user to understand, so I am going to make the changes any way.

Wordpress is also changing - with 3.0 coming out really soon now - and I wanted to make my install more multiblog friendly : so 4 tables per WP install rather than 4 tables per blog which means some quite jolly logic to work out if you are in WP2 (or WPMU2) or WP3 (running in single or multiple blog mode)

So I'm revisiting my old code and wondering if I should really throw 80% of it away and strip away the crud and spaghetti that seems to have collected during my rapid development of the project. I've now got a much clearer idea of how things should work and how the code should flow, and how to code round the countless "failures" of the FB back end which occur at depressingly frequently intervals, some of which I did last night when a couple of users were basically stuck because FB were playing round with code on the live servers again.

 

]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/wFtCHjaGTzwMXTuaT6lLeWjKuTg/0/da"><img src="http://feedads.g.doubleclick.net/~a/wFtCHjaGTzwMXTuaT6lLeWjKuTg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/wFtCHjaGTzwMXTuaT6lLeWjKuTg/1/da"><img src="http://feedads.g.doubleclick.net/~a/wFtCHjaGTzwMXTuaT6lLeWjKuTg/1/di" border="0" ismap="true"></img></a></p>Nick commented once about some of the code in <a href="http://www.canalplan.org.uk/">CanalPlan AC </a>and how it was suffering from "bit rot". Basically code that you shoved in, often as a quick dirty fix and  then it starts to fail but with no good reason.

Well <a href="http://wordpress.org/extend/plugins/wordbooker/">Wordbooker</a> is suffering from bit rot, its just that luckily no-one has noticed it yet, well apart from me that is.

Wordbooker took code written by Robert Tsai for his plugin (Wordbook) and extended it. That is why Wordbooker is called Wordbooker - because it stands for WordbookE[xtended]R[elease].  Robert's code used to support the Wordpress PHP libraries for PHP4 and PHP5. PHP4 support was dropped but the wrappers were left inside the code, adding a level of abstraction around the calls to the Facebook PHP libraries.

When I added all the new features such as posting to walls and FB widgets and so on, into his code I sometimes used his wrappers and sometimes made the calls directly.  

Facebook then depreciated some functionality and so calls to functions supporting that got commented out and eventually I stripped most of the code out.

I'd added functionality to handle comments really as a sort of proof of concept and then I added posting support to pages, but comments to pages didn't get processed properly due to slight differences inside FB on how pages are handled.

So that was the next big project - re-write comment handling to make it a lot more robust (and at the same time simpler). 

But then Facebook came along with the Graph API and the Oauth authentication process and said that all applications would be force migrated to the new Authentication method on June 1st.  The new Graph API would make my job simpler as I only use a few calls (post to wall, post comment, get comment, get status, and a few FQL calls) and so obviously I should think about moving my code to use it.

That wouldn't be bad if the Graph API was complete and not riddled with bugs (for example if you include a link in a post it thinks you are doing a "share" style post and goes and scrapes that URL - something which is not right and not how the old API works),  but as it is I can't use the new API for anything but authentication, so I've had to work out how to use the Oauth method for signing on, but then use the old API for the rest of my code, all under the looming date of the end of the month and with me working a day job as well.

Facebook also changed their policy on posting to walls and I asked them for clarification, and they asked for more information which I've given them, and now I'm waiting to hear back from them. It could mean that I have to change my code, but actually it will make the process easier to code and make it easier for the user to understand, so I am going to make the changes any way.

Wordpress is also changing - with 3.0 coming out really soon now - and I wanted to make my install more multiblog friendly : so 4 tables per WP install rather than 4 tables per blog which means some quite jolly logic to work out if you are in WP2 (or WPMU2) or WP3 (running in single or multiple blog mode)

So I'm revisiting my old code and wondering if I should really throw 80% of it away and strip away the crud and spaghetti that seems to have collected during my rapid development of the project. I've now got a much clearer idea of how things should work and how the code should flow, and how to code round the countless "failures" of the FB back end which occur at depressingly frequently intervals, some of which I did last night when a couple of users were basically stuck because FB were playing round with code on the live servers again.

 

<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/esiF0NdprYI" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2010/05/19/revisiting-old-code/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2010/05/19/revisiting-old-code/</feedburner:origLink></item>
						<item>
				<title>So much for Mobile broadband</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/se1259KADxo/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2010/05/12/so-much-for-mobile-broadband/#comments</comments>
				<pubDate>Wed, 12 May 2010 12:25:32 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2010/05/12/so-much-for-mobile-broadband/</guid>
                <description><![CDATA[Was trying to check a problem with<a href="http://www.canalplan.org.uk"> Canalplan AC</a> today and as its sitting on the server in the living room I thought I should try it "remotely" rather than access off the local network.

So I got the O2 broadband dongle and powered it up and connected, and couldn't reproduce the error... Oh well, thats how things go, especially when you are talking about IE8.

So whilst I was connected I thought I'd just hop onto this blog site and check a couple of things.

Sorry - No Can Do! Not Possible. Kept telling me the site was not available.

But it sits on the same server as Canalplan AC. It sits on blogs.canalplan.org.uk when Canalplan is on www.canalplan.org.uk.

So if one responds, then the other other should. Right?

Well you are wrong:

Here is the output of a ping command:
<pre>Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Users\steve&gt;ping www.canalplan.org.uk

Pinging www.canalplan.org.uk [212.159.61.36] with 32 bytes of data:
</pre>

So that's good  - its getting the IP address. It wont ever respond to pings because the router dumps them.

So lets try for the blogs:

<pre>
Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Users\steve&gt;ping blogs.canalplan.org.uk
Ping request could not find host blogs.canalplan.org.uk. Please check the name and try again.
</pre>

Nope - its not there.

The DNS servers for O2 don't recognise it as a valid host name.

Tosspots.

OR rather its their Windows software that is screwy. If I power up under Linux then it works fine!
]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/YuGE7161bCiia8OyGUoObhML6bM/0/da"><img src="http://feedads.g.doubleclick.net/~a/YuGE7161bCiia8OyGUoObhML6bM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/YuGE7161bCiia8OyGUoObhML6bM/1/da"><img src="http://feedads.g.doubleclick.net/~a/YuGE7161bCiia8OyGUoObhML6bM/1/di" border="0" ismap="true"></img></a></p>Was trying to check a problem with<a href="http://www.canalplan.org.uk"> Canalplan AC</a> today and as its sitting on the server in the living room I thought I should try it "remotely" rather than access off the local network.

So I got the O2 broadband dongle and powered it up and connected, and couldn't reproduce the error... Oh well, thats how things go, especially when you are talking about IE8.

So whilst I was connected I thought I'd just hop onto this blog site and check a couple of things.

Sorry - No Can Do! Not Possible. Kept telling me the site was not available.

But it sits on the same server as Canalplan AC. It sits on blogs.canalplan.org.uk when Canalplan is on www.canalplan.org.uk.

So if one responds, then the other other should. Right?

Well you are wrong:

Here is the output of a ping command:
<pre>Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Users\steve&gt;ping www.canalplan.org.uk

Pinging www.canalplan.org.uk [212.159.61.36] with 32 bytes of data:
</pre>

So that's good  - its getting the IP address. It wont ever respond to pings because the router dumps them.

So lets try for the blogs:

<pre>
Microsoft Windows [Version 6.0.6002]
Copyright (c) 2006 Microsoft Corporation.  All rights reserved.

C:\Users\steve&gt;ping blogs.canalplan.org.uk
Ping request could not find host blogs.canalplan.org.uk. Please check the name and try again.
</pre>

Nope - its not there.

The DNS servers for O2 don't recognise it as a valid host name.

Tosspots.

OR rather its their Windows software that is screwy. If I power up under Linux then it works fine!
<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/se1259KADxo" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2010/05/12/so-much-for-mobile-broadband/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2010/05/12/so-much-for-mobile-broadband/</feedburner:origLink></item>
						<item>
				<title>Using the new Facebook Graph API off-line</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/H6RY7y85H0Q/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2010/05/05/using-the-new-facebook-graph-api-off-line/#comments</comments>
				<pubDate>Wed, 05 May 2010 12:29:05 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2010/05/05/using-the-new-facebook-graph-api-off-line/</guid>
                <description><![CDATA[One of the features of the old Facebook API was "off-line" access - basically where you could interact with Facebook in a "non-interactive" way : in other words a program or script could interact with Facebook on your behalf without you having to have a Facebook window open in your browser.

The new API also supports this but the documentation is not really totally clear on the "process" needed to do it.

So I sat down and worked it out. The code you are about to see is not neat, or tidy. It contains no proper error handling or checking apart from the bare minimum needed to make it work.

<strong><span style="font-size: large">Pre-requisites</span>
</strong>
You will need:
<ul>
	<li>A Webserver</li>
	<li>PHP V5.x with CURL enabled</li>
	<li>A MySQL Database.</li>
	<li><a title="Link to Facebook" href="http://www.facebook.com" target="_blank">A Facebook Account</a> (preferably a developer account unless your friends like being spammed)</li>
	<li><a title="Link to Facebook Create App Page" href="http://www.facebook.com/developers/createapp.php" target="_blank">A Facebook Application</a></li>
	<li>The Facebook Graph PHP-SDK which is available from the <a href="http://github.com/facebook/php-sdk" target="_blank">GitHub repository</a>.</li>
</ul>
First of all we need to make sure that we have a table to store the session data in. We are actually storing all the session data : this might be overkill but as a lot of this is still undocumented I felt it was safer to store everything.

So at the start of our example lets do the dirty work with the database. If you were doing this properly you'd have this in a function which you called once, for example with a Wordpress plugin you'd call it on plugin activation. But we're not doing that here so .... and don't forget to change those db_  parameters to match your system.
<pre>$db_server = "localhost";
$db_username = "dbuser";
$db_password = "dbpassword";
$db_name = "dbname";

# Lets connect to the Database and set up the table
mysql_connect($db_server,$db_username,$db_password);
mysql_select_db($db_name);
$ct_res = mysql_query("CREATE TABLE IF NOT EXISTS `facebook_user` (
   `session_key` VARCHAR( 80 ) NOT NULL ,
   `uid` VARCHAR( 80 ) NOT NULL ,
   `expires` VARCHAR( 80 ) NOT NULL ,
   `secret` VARCHAR( 80 ) NOT NULL ,
   `access_token` VARCHAR( 120 ) NOT NULL ,
   `sig` VARCHAR( 80 ) NOT NULL
   );"
);</pre>
OK So that's the DB work done and each time we run the script it will create the table if its not there. Now we can set up the Facebook side of things. Don't forget to change the path for the facebook.php file (which you did download  didn't you?). You'll also need the information about the Facebook Application you<a title="Link to Facebook Create App Page" href="http://www.facebook.com/developers/createapp.php" target="_blank"> set up </a> because I'm not letting you share mine! You may also want to review the permissions that are being granted - the ones in this code are the ones my <a title="link to Wordbooker page on Wordperess" href="http://wordpress.org/extend/plugins/wordbooker/" target="_blank">Wordbooker </a>application uses
<pre># Now lets load the FB GRAPH API
require '../src/facebook.php';

// Create our Application instance.
global $facebook;
$facebook = new Facebook(array(
 'appId'  =&gt; '101001010101010101',
 'secret' =&gt; 'faafaffdfasdffsafsfsddfasd',
 'cookie' =&gt; false,
));

# Lets set up the permissions we need and set the login url in case we need it.
$par['req_perms'] = "publish_stream,
                    offline_access,
                    user_status,
                    read_stream,
                    email,
                    user_groups";
$loginUrl = $facebook-&gt;getLoginUrl($par);</pre>
The "heart" of the code is the get_check_session function. This function checks to see if we have a session stored in the database and if we do it returns it. If we don't have a session but a session is being passed in via the URL it gets it, stores it and then returns it. If neither of these cases are true it returns nothing.
<pre>function get_check_session(){
  global $facebook;
  # This function basically checks for a stored session and if we have one returns it,
  #If we have no stored session then it gets one and stores it
  # OK lets go to the database and see if we have a session stored
  $sid=mysql_query("Select access_token from facebook_user");
  $session_id=mysql_fetch_row($sid);
  if (is_array($session_id)) {
    # We have a session ID so lets not get a new one
    # Put some session checking in here to make sure its valid
   try {
     $attachment =  array('access_token' =&gt; $session_id[0],);
     $ret_code=$facebook-&gt;api('/me', 'GET', $attachment);
    }
     catch (Exception $e) {
       # We don't have a good session so
       echo "woops";
      $res = mysql_query('delete from facebook_user where expires=0');
      return;
    }
  return $session_id[0];
 } 

 {
  # Are we coming back from a login with a session set?
  $session = $facebook-&gt;getSession();
  if (is_array($session)) {
   # Yes! so lets store it!
   $sql="insert into facebook_user (
               session_key,
               uid,
               expires,
               secret,
               access_token,
               sig)
             VALUES ('".$session['session_key']."','".
                        $session['uid']."','".
                        $session['expires']."','".
                        $session['secret'] ."','".
                        $session['access_token']."','".
                        $session['sig']."');";
   $res = mysql_query($sql);
   return $session['access_token'];
  }
 }
}</pre>
OK, believe it or not we are just about there with only a few more lines of code to go. Are you ready?
<pre>$access_token=get_check_session();
# If we've not got an access_token we need to login.
if ( is_null($access_token) ) {
echo '&lt;a href="'. $loginUrl.'"&gt;&lt;
img src="http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif" alt="" /&gt; ';
}
else {

# This is where you put your code.
$target=1010101010100110;
$attachment =  array(
 'access_token' =&gt; $access_token,
 'message' =&gt; 'Did a Test Post :',
 'name' =&gt; "Offline posting using stored tokens",
   'link' =&gt; "http://blogs.canalplan.org.uk/steve/2010/05/05/using-the-new-facebook-graph-api-off-line/",
  'description' =&gt; "This post was made using a stored access token",
  'picture'=&gt;http://blogs.canalplan.org.uk/steve/files/2010/05/Screenshot-5-300x194.png",
			);

$ret_code=$facebook-&gt;api('/'.$target.'/feed', 'POST', $attachment);

echo "Returns : ";
var_dump($ret_code);
echo ""; 

$attachment =  array(
'access_token' =&gt; $access_token,
 'message' =&gt; "and this is a comment I've just made on the post using that same stored token",);

$ret_code=$facebook-&gt;api('/'.$ret_code['id'].'/comments', 'POST', $attachment);

echo "Returns : ";
var_dump($ret_code);
echo ""; 

}
</pre>
Basically any code in the ELSE {} block is executed if you have a Facebook access_token. In the example what we do is post a message to a "target" which is a FB user ID (you can use names rather than numbers), and then we immediately comment on it. Which produces something like:

[caption id="attachment_905" align="alignnone" width="300" caption="A Wall post and an associated comment made by the php code."]<a href="http://blogs.canalplan.org.uk/steve/files/2010/05/Screenshot-5.png"><img class="size-medium wp-image-905" title="Screenshot-5" src="http://blogs.canalplan.org.uk/steve/files/2010/05/Screenshot-5-300x194.png" alt="image showing FB wall postings" width="300" height="194" /></a>[/caption]

So there you go. Why not <a href="http://www.pemmaquid.plus.com/example3.php">download the code</a> and give it a go.]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/AyLmfbykqUcWTYKADDowrGX1Wb4/0/da"><img src="http://feedads.g.doubleclick.net/~a/AyLmfbykqUcWTYKADDowrGX1Wb4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/AyLmfbykqUcWTYKADDowrGX1Wb4/1/da"><img src="http://feedads.g.doubleclick.net/~a/AyLmfbykqUcWTYKADDowrGX1Wb4/1/di" border="0" ismap="true"></img></a></p>One of the features of the old Facebook API was "off-line" access - basically where you could interact with Facebook in a "non-interactive" way : in other words a program or script could interact with Facebook on your behalf without you having to have a Facebook window open in your browser.

The new API also supports this but the documentation is not really totally clear on the "process" needed to do it.

So I sat down and worked it out. The code you are about to see is not neat, or tidy. It contains no proper error handling or checking apart from the bare minimum needed to make it work.

<strong><span style="font-size: large">Pre-requisites</span>
</strong>
You will need:
<ul>
	<li>A Webserver</li>
	<li>PHP V5.x with CURL enabled</li>
	<li>A MySQL Database.</li>
	<li><a title="Link to Facebook" href="http://www.facebook.com" target="_blank">A Facebook Account</a> (preferably a developer account unless your friends like being spammed)</li>
	<li><a title="Link to Facebook Create App Page" href="http://www.facebook.com/developers/createapp.php" target="_blank">A Facebook Application</a></li>
	<li>The Facebook Graph PHP-SDK which is available from the <a href="http://github.com/facebook/php-sdk" target="_blank">GitHub repository</a>.</li>
</ul>
First of all we need to make sure that we have a table to store the session data in. We are actually storing all the session data : this might be overkill but as a lot of this is still undocumented I felt it was safer to store everything.

So at the start of our example lets do the dirty work with the database. If you were doing this properly you'd have this in a function which you called once, for example with a Wordpress plugin you'd call it on plugin activation. But we're not doing that here so .... and don't forget to change those db_  parameters to match your system.
<pre>$db_server = "localhost";
$db_username = "dbuser";
$db_password = "dbpassword";
$db_name = "dbname";

# Lets connect to the Database and set up the table
mysql_connect($db_server,$db_username,$db_password);
mysql_select_db($db_name);
$ct_res = mysql_query("CREATE TABLE IF NOT EXISTS `facebook_user` (
   `session_key` VARCHAR( 80 ) NOT NULL ,
   `uid` VARCHAR( 80 ) NOT NULL ,
   `expires` VARCHAR( 80 ) NOT NULL ,
   `secret` VARCHAR( 80 ) NOT NULL ,
   `access_token` VARCHAR( 120 ) NOT NULL ,
   `sig` VARCHAR( 80 ) NOT NULL
   );"
);</pre>
OK So that's the DB work done and each time we run the script it will create the table if its not there. Now we can set up the Facebook side of things. Don't forget to change the path for the facebook.php file (which you did download  didn't you?). You'll also need the information about the Facebook Application you<a title="Link to Facebook Create App Page" href="http://www.facebook.com/developers/createapp.php" target="_blank"> set up </a> because I'm not letting you share mine! You may also want to review the permissions that are being granted - the ones in this code are the ones my <a title="link to Wordbooker page on Wordperess" href="http://wordpress.org/extend/plugins/wordbooker/" target="_blank">Wordbooker </a>application uses
<pre># Now lets load the FB GRAPH API
require '../src/facebook.php';

// Create our Application instance.
global $facebook;
$facebook = new Facebook(array(
 'appId'  =&gt; '101001010101010101',
 'secret' =&gt; 'faafaffdfasdffsafsfsddfasd',
 'cookie' =&gt; false,
));

# Lets set up the permissions we need and set the login url in case we need it.
$par['req_perms'] = "publish_stream,
                    offline_access,
                    user_status,
                    read_stream,
                    email,
                    user_groups";
$loginUrl = $facebook-&gt;getLoginUrl($par);</pre>
The "heart" of the code is the get_check_session function. This function checks to see if we have a session stored in the database and if we do it returns it. If we don't have a session but a session is being passed in via the URL it gets it, stores it and then returns it. If neither of these cases are true it returns nothing.
<pre>function get_check_session(){
  global $facebook;
  # This function basically checks for a stored session and if we have one returns it,
  #If we have no stored session then it gets one and stores it
  # OK lets go to the database and see if we have a session stored
  $sid=mysql_query("Select access_token from facebook_user");
  $session_id=mysql_fetch_row($sid);
  if (is_array($session_id)) {
    # We have a session ID so lets not get a new one
    # Put some session checking in here to make sure its valid
   try {
     $attachment =  array('access_token' =&gt; $session_id[0],);
     $ret_code=$facebook-&gt;api('/me', 'GET', $attachment);
    }
     catch (Exception $e) {
       # We don't have a good session so
       echo "woops";
      $res = mysql_query('delete from facebook_user where expires=0');
      return;
    }
  return $session_id[0];
 } 

 {
  # Are we coming back from a login with a session set?
  $session = $facebook-&gt;getSession();
  if (is_array($session)) {
   # Yes! so lets store it!
   $sql="insert into facebook_user (
               session_key,
               uid,
               expires,
               secret,
               access_token,
               sig)
             VALUES ('".$session['session_key']."','".
                        $session['uid']."','".
                        $session['expires']."','".
                        $session['secret'] ."','".
                        $session['access_token']."','".
                        $session['sig']."');";
   $res = mysql_query($sql);
   return $session['access_token'];
  }
 }
}</pre>
OK, believe it or not we are just about there with only a few more lines of code to go. Are you ready?
<pre>$access_token=get_check_session();
# If we've not got an access_token we need to login.
if ( is_null($access_token) ) {
echo '&lt;a href="'. $loginUrl.'"&gt;&lt;
img src="http://static.ak.fbcdn.net/rsrc.php/zB6N8/hash/4li2k73z.gif" alt="" /&gt; ';
}
else {

# This is where you put your code.
$target=1010101010100110;
$attachment =  array(
 'access_token' =&gt; $access_token,
 'message' =&gt; 'Did a Test Post :',
 'name' =&gt; "Offline posting using stored tokens",
   'link' =&gt; "http://blogs.canalplan.org.uk/steve/2010/05/05/using-the-new-facebook-graph-api-off-line/",
  'description' =&gt; "This post was made using a stored access token",
  'picture'=&gt;http://blogs.canalplan.org.uk/steve/files/2010/05/Screenshot-5-300x194.png",
			);

$ret_code=$facebook-&gt;api('/'.$target.'/feed', 'POST', $attachment);

echo "Returns : ";
var_dump($ret_code);
echo ""; 

$attachment =  array(
'access_token' =&gt; $access_token,
 'message' =&gt; "and this is a comment I've just made on the post using that same stored token",);

$ret_code=$facebook-&gt;api('/'.$ret_code['id'].'/comments', 'POST', $attachment);

echo "Returns : ";
var_dump($ret_code);
echo ""; 

}
</pre>
Basically any code in the ELSE {} block is executed if you have a Facebook access_token. In the example what we do is post a message to a "target" which is a FB user ID (you can use names rather than numbers), and then we immediately comment on it. Which produces something like:

[caption id="attachment_905" align="alignnone" width="300" caption="A Wall post and an associated comment made by the php code."]<a href="http://blogs.canalplan.org.uk/steve/files/2010/05/Screenshot-5.png"><img class="size-medium wp-image-905" title="Screenshot-5" src="http://blogs.canalplan.org.uk/steve/files/2010/05/Screenshot-5-300x194.png" alt="image showing FB wall postings" width="300" height="194" /></a>[/caption]

So there you go. Why not <a href="http://www.pemmaquid.plus.com/example3.php">download the code</a> and give it a go.<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/H6RY7y85H0Q" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2010/05/05/using-the-new-facebook-graph-api-off-line/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2010/05/05/using-the-new-facebook-graph-api-off-line/</feedburner:origLink></item>
						<item>
				<title>Hitting a moving Target</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/KQzIahOxbpk/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2010/04/28/hitting-a-moving-target/#comments</comments>
				<pubDate>Wed, 28 Apr 2010 09:47:42 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2010/04/28/hitting-a-moving-target/</guid>
                <description><![CDATA[Things move fast in the IT world:  Oracle spit out a new version of their database every couple of years, Microsoft keep.... well actually the less said about Microsoft the better to be honest, and as for Apple......  :roll:

I've been coding away on my <a href="http://wordpress.org/extend/plugins/wordbooker/">Wordbooker Plugin</a> since the tail end of last year. I had great plans for version 1.8.  I was going to add internationalisation and completely rebuild comment handling from the ground up as its not really working properly.. Hey I coded it in a day and bolted it onto the existing code so what else would you expect...

So I'd got all these plans worked out in my head and then along came Facebook and their developer conference (F8) who shoved a huge great spanner into the works.

Now for those who have never tried programming against the Facebook API you wont know just how annoying it is. It is rather like trying to nail jelly to the ceiling : Facebook quite happily change the API on the live site without telling anyone which breaks things. Go on.. how many times have you seen the "Oops, something seems to have gone wrong" message? Well developers get that too - or rather they get calls that suddenly return no data, or incorrect and incomplete data, or error codes they've never seen before.

People file bug reports and Facebook go and change the documentation and then deny its an error. Or Facebook fix the bug and everything is fine for a few weeks then it re-occurs which suggests a lack of a proper test and release process. The worst one I've seen is a bug which apparently "fixed" itself with Facebook representatives saying they did not know what had caused the problem or why it was now working again. The PHP files they provide don't even have version IDs in them so you can't tell if you've got the latest version, or <em>worse still</em> : you can't determine the version of the files that another Wordpress plugin might have installed - so your code doesn't work because the version of the Facebook files they have installed doesn't have the function, or class, you need for your code to work.

So any way, along comes F8 and a whole new way of interfacing with Facebook : The Graph API, and along with that came a new data model and a new data permissions dialogue, and a new Data policy. Everything new and shiny and the statement that "On June 1, 2010, we'll automatically transition all Facebook Platform  applications and websites who have not yet migrated."

Sounds good doesn't it. Apart from the fact that no-one at Facebook has explained how you can use the new Data permissions dialogue with the "old" API, and everything I've tried simply comes back with meaningless errors, and from what I've read other developers have experienced the same problems.

So I guess I could just convert my application over to the new API couldn't I, that would make things easier wouldn't it? Ahhh..............actually I can't because Facebook haven't actually written the PHP API libraries yet - well not to the point of supporting "offline" access, which is what my application relies on. Actually that last bit says a lot about Facebook : They announce a whole new API and a whole new data structure, but the only way to access it is hand crafting your own CURL statements and running a "live" Facebook session. Talk about the right hand not knowing what the left is doing....

Madness]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/1nCCE-J_01Ehpw1VeW0D-oh_thk/0/da"><img src="http://feedads.g.doubleclick.net/~a/1nCCE-J_01Ehpw1VeW0D-oh_thk/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/1nCCE-J_01Ehpw1VeW0D-oh_thk/1/da"><img src="http://feedads.g.doubleclick.net/~a/1nCCE-J_01Ehpw1VeW0D-oh_thk/1/di" border="0" ismap="true"></img></a></p>Things move fast in the IT world:  Oracle spit out a new version of their database every couple of years, Microsoft keep.... well actually the less said about Microsoft the better to be honest, and as for Apple......  :roll:

I've been coding away on my <a href="http://wordpress.org/extend/plugins/wordbooker/">Wordbooker Plugin</a> since the tail end of last year. I had great plans for version 1.8.  I was going to add internationalisation and completely rebuild comment handling from the ground up as its not really working properly.. Hey I coded it in a day and bolted it onto the existing code so what else would you expect...

So I'd got all these plans worked out in my head and then along came Facebook and their developer conference (F8) who shoved a huge great spanner into the works.

Now for those who have never tried programming against the Facebook API you wont know just how annoying it is. It is rather like trying to nail jelly to the ceiling : Facebook quite happily change the API on the live site without telling anyone which breaks things. Go on.. how many times have you seen the "Oops, something seems to have gone wrong" message? Well developers get that too - or rather they get calls that suddenly return no data, or incorrect and incomplete data, or error codes they've never seen before.

People file bug reports and Facebook go and change the documentation and then deny its an error. Or Facebook fix the bug and everything is fine for a few weeks then it re-occurs which suggests a lack of a proper test and release process. The worst one I've seen is a bug which apparently "fixed" itself with Facebook representatives saying they did not know what had caused the problem or why it was now working again. The PHP files they provide don't even have version IDs in them so you can't tell if you've got the latest version, or <em>worse still</em> : you can't determine the version of the files that another Wordpress plugin might have installed - so your code doesn't work because the version of the Facebook files they have installed doesn't have the function, or class, you need for your code to work.

So any way, along comes F8 and a whole new way of interfacing with Facebook : The Graph API, and along with that came a new data model and a new data permissions dialogue, and a new Data policy. Everything new and shiny and the statement that "On June 1, 2010, we'll automatically transition all Facebook Platform  applications and websites who have not yet migrated."

Sounds good doesn't it. Apart from the fact that no-one at Facebook has explained how you can use the new Data permissions dialogue with the "old" API, and everything I've tried simply comes back with meaningless errors, and from what I've read other developers have experienced the same problems.

So I guess I could just convert my application over to the new API couldn't I, that would make things easier wouldn't it? Ahhh..............actually I can't because Facebook haven't actually written the PHP API libraries yet - well not to the point of supporting "offline" access, which is what my application relies on. Actually that last bit says a lot about Facebook : They announce a whole new API and a whole new data structure, but the only way to access it is hand crafting your own CURL statements and running a "live" Facebook session. Talk about the right hand not knowing what the left is doing....

Madness<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/KQzIahOxbpk" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2010/04/28/hitting-a-moving-target/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2010/04/28/hitting-a-moving-target/</feedburner:origLink></item>
						<item>
				<title>Update</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/cFpBKDtDipk/</link>
				<comments>http://blogs.canalplan.org.uk/blog/2010/04/23/update-2/#comments</comments>
				<pubDate>Fri, 23 Apr 2010 08:50:27 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/blog/2010/04/23/update-2/</guid>
                <description><![CDATA[As you might have noticed - not a lot has been going on here, apart from the continual chasing of Wordpress upgrades and the upgrades to the various plugins.

Most of the integration with Canalplan is now complete and I've been working a lot on <a title="Link to Wordbooker Page" href="http://wordpress.org/extend/plugins/wordbooker/" target="_blank">Wordbooker</a> which is a Wordpress plugin that connects Wordpress blogs with Facebook.]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/iOqKOz7PZ4ZOZB2xxCnerHvbxJs/0/da"><img src="http://feedads.g.doubleclick.net/~a/iOqKOz7PZ4ZOZB2xxCnerHvbxJs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/iOqKOz7PZ4ZOZB2xxCnerHvbxJs/1/da"><img src="http://feedads.g.doubleclick.net/~a/iOqKOz7PZ4ZOZB2xxCnerHvbxJs/1/di" border="0" ismap="true"></img></a></p>As you might have noticed - not a lot has been going on here, apart from the continual chasing of Wordpress upgrades and the upgrades to the various plugins.

Most of the integration with Canalplan is now complete and I've been working a lot on <a title="Link to Wordbooker Page" href="http://wordpress.org/extend/plugins/wordbooker/" target="_blank">Wordbooker</a> which is a Wordpress plugin that connects Wordpress blogs with Facebook.<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/cFpBKDtDipk" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/blog/2010/04/23/update-2/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/blog/2010/04/23/update-2/</feedburner:origLink></item>
						<item>
				<title>The importance of testing</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/iJhJJsrvE9M/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2010/02/24/the-importance-of-testing/#comments</comments>
				<pubDate>Wed, 24 Feb 2010 13:31:52 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2010/02/24/the-importance-of-testing/</guid>
                <description><![CDATA[When I started the fork of Robert Tsai's <a href="http://wordpress.org/extend/plugins/wordbook/">Wordbook</a> plugin, which I rebranded as <a href="http://wordpress.org/extend/plugins/wordbooker/">Wordbooker</a>, I was pushing out version after version very quickly: Version 1.0 came out on 02/01/2010 and I was up to Version 1.5 by 10/01/2010.

Things have slowed down a bit now, and Version 1.6 was released on 22/01/2010 with 1.6.1 (which allowed posting to Fan Page Walls) coming out on 29/01/2010.

Version 1.7 is still being worked on - and I'm up to Beta 7, and about to push Beta 8 out later today which fixes some minor annoyance.

These Betas have been a mix of code fixes, code enhancements to work round various Wordpress plugins, and fixes to HTML to get things working across the user "landscape".

I do all my development on a Medion  S5610 Laptop running Ubuntu 9.10. So I've got Firefox 3.6, Opera 10.10, Chromium 5.0.336.0 (39849)  and Chrome installed as browsers. If I reboot into Windows then I can test on Firefox 3.6 , Opera 10, Chrome, Safari, and Internet Explorer 8. That still leaves the Mac platform as a complete blank space where I can't test, plus any other versions of Internet Explorer.

It wouldn't be bad if all the browsers behaved the same but they don't. Chrome for example craps out if you forget to close label tags - its obviously something to do with nesting that eventually blows something up, but I don't know what it is.

Internet Explorer 8's implementation of Javascript blows up on some drag and drop functionality provided by Wordpress for its widget management page. No other browser seems to be quite so anal about null objects as IE is for some reason, and I've just spent an hour or so debugging it, and it was down to not including an object class inside a php text call (No don't ask.. I don't know why either)

So that's why I've been pushing out Betas because I can't test every single combination of operating system/browser/Wordpress version/active Wordpress plugins.

Of course it doesn't help that Facebook doesn't always play ball properly - I spent about 2 hours chasing an image posting problem just to find that it was Facebook acting up.

Now all I've got to do is get people to use the beta versions and give me feedback on bugs.... that makes my part of the job look easy!]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/Zwh3bs_0_y0iQoNLageCgxnaDQc/0/da"><img src="http://feedads.g.doubleclick.net/~a/Zwh3bs_0_y0iQoNLageCgxnaDQc/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Zwh3bs_0_y0iQoNLageCgxnaDQc/1/da"><img src="http://feedads.g.doubleclick.net/~a/Zwh3bs_0_y0iQoNLageCgxnaDQc/1/di" border="0" ismap="true"></img></a></p>When I started the fork of Robert Tsai's <a href="http://wordpress.org/extend/plugins/wordbook/">Wordbook</a> plugin, which I rebranded as <a href="http://wordpress.org/extend/plugins/wordbooker/">Wordbooker</a>, I was pushing out version after version very quickly: Version 1.0 came out on 02/01/2010 and I was up to Version 1.5 by 10/01/2010.

Things have slowed down a bit now, and Version 1.6 was released on 22/01/2010 with 1.6.1 (which allowed posting to Fan Page Walls) coming out on 29/01/2010.

Version 1.7 is still being worked on - and I'm up to Beta 7, and about to push Beta 8 out later today which fixes some minor annoyance.

These Betas have been a mix of code fixes, code enhancements to work round various Wordpress plugins, and fixes to HTML to get things working across the user "landscape".

I do all my development on a Medion  S5610 Laptop running Ubuntu 9.10. So I've got Firefox 3.6, Opera 10.10, Chromium 5.0.336.0 (39849)  and Chrome installed as browsers. If I reboot into Windows then I can test on Firefox 3.6 , Opera 10, Chrome, Safari, and Internet Explorer 8. That still leaves the Mac platform as a complete blank space where I can't test, plus any other versions of Internet Explorer.

It wouldn't be bad if all the browsers behaved the same but they don't. Chrome for example craps out if you forget to close label tags - its obviously something to do with nesting that eventually blows something up, but I don't know what it is.

Internet Explorer 8's implementation of Javascript blows up on some drag and drop functionality provided by Wordpress for its widget management page. No other browser seems to be quite so anal about null objects as IE is for some reason, and I've just spent an hour or so debugging it, and it was down to not including an object class inside a php text call (No don't ask.. I don't know why either)

So that's why I've been pushing out Betas because I can't test every single combination of operating system/browser/Wordpress version/active Wordpress plugins.

Of course it doesn't help that Facebook doesn't always play ball properly - I spent about 2 hours chasing an image posting problem just to find that it was Facebook acting up.

Now all I've got to do is get people to use the beta versions and give me feedback on bugs.... that makes my part of the job look easy!<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/iJhJJsrvE9M" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2010/02/24/the-importance-of-testing/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2010/02/24/the-importance-of-testing/</feedburner:origLink></item>
						<item>
				<title>Wordpress and Facebook Integration</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/3YxMctJ_oDg/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2010/01/02/wordpress-and-facebook-integration/#comments</comments>
				<pubDate>Sat, 02 Jan 2010 17:49:33 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2010/01/02/wordpress-and-facebook-integration/</guid>
                <description><![CDATA[I'd been using the <a title="Link to Wordbook Application on Facebook" href="http://www.facebook.com/apps/application.php?id=3353257731" target="_blank">Wordbook app</a> for quite a bit but I'd always found that it lacked some features that I liked. I've now added these functions and got it doing things how I'd like.

So rather than keep cluttering up the original wordbook application page I've forked by code off totally.

I created a new Facebook application called <a title="Link to Wordbooker Application on Facebook" href="http://www.facebook.com/apps/application.php?id=254577506873" target="_blank">Wordbooker</a> and then created a new plugin called <a title="Link to the Wordbooker extension at Wordpress" href="http://wordpress.org/extend/plugins/wordbooker/" target="_blank">Wordbooker</a> in the Wordpress Extensions site.

<strong><span style="font-size: medium">Upgrading from the Forked Version.</span></strong>

As this is basically a new application its a bit messy as doing a normal removal of the old forked version will remove any record of posts/comments made with the forked version.

If you wish to retain that history then you need to back up the existing wordbook_postcomments table BEFORE you remove the forked version of wordbook.

Go into the options page for Wordbook and reset the configuration for wordbook

From the plugins page de-activate the wordbook plugin.

Delete the wordbook directory from wp-content/plugins

Upload the wordbooker directory into the wp-content/plugins directory

Go into the Plugins page and enable Wordbooker.

Go to the options page for Wordbooker and  it will ask you to get a login key from Facebook and then ask you to grant two extra permissions needed by Wordbooker - these allow Wordbooker to publish to your wall and also to fetch comments from it.

Click on the Save Configuration button.

You can then set up the various options on the option screen:

[caption id="attachment_734" align="alignnone" width="300" caption="Wordbooker Options page"]<a href="http://blogs.canalplan.org.uk/steve/files/2010/01/wb-options.png"><img class="size-medium wp-image-734" title="wb-options" src="http://blogs.canalplan.org.uk/steve/files/2010/01/wb-options-300x158.png" alt="Wordbooker Options page" width="300" height="158" /></a>[/caption]

<strong>** Multiple Facebook account / WordPress account support **</strong>

If you as the blog owner only want it so that WP posts go to your FB account then go into the Options screen and set the default account to be yours, and that should be it, any person using a different WP account to post to your blog will publish those stories to your FB account.

But what if you've got a Family WB where different people would like to post to WP and to their OWN FB accounts. Simply get each of them to login to WP as themselves and configure WB as if they were the only user. Then when all of them have done this go back in as yourself and set the Default account to be you.

On the Edit Post page there is a WordBook Options block which includes a drop down list of the blog you wish to post to, if you want to post to your default blog then you don't need to touch this but if someone wants to post that post to their FB account all they need to do is pick their name from the drop down list before they post.

<strong>** Length of Extract **</strong>
This allows you to change the length of the extract posted to Facebook. The minimum value is 200 and the maximum is 400 (at the moment) with the default being 256 characters. The extract will be trimmed to the nearest full word BELOW this value.

<strong>** Default Publish Post to Facebook **</strong>

This allows you to choose if posts should automatically be posted to Facebook. This option can be overridden from the Edit Post page

<strong>** Post Attribute **</strong>

This allows you to change the attribute line when posts are sent to Facebook. By default this is set to "Posted a new post on their blog". This option can be overridden from the Edit Post page.

<strong>** Republish Post if edited more than x days ago **</strong>

This allows you to control how long it should be before Wordbook considers an edited post to be a "new" post and re-publishes it to Facebook.

<strong>** Override Re-Publication window  **</strong>

This allows to to force all edits to be reposted to Facebook ignoring the republish window. This option can be overridden from the Edit Post page.

<strong>** Update Facebook Status **</strong>
If this option is checked then the title of your blog post and its permalink will be posted to your status, along with the text specified here. This can be overridden from the Edit Post page. NOTE: If this option is Selected then your status is ALWAYS updated, even if you choose NOT to publish your post to Facebook.

<strong>** Import Comments from Facebook for Wordbook Posts  **</strong>

This version of Wordbook supports the importing of comments made on Facebook back into your WordPress blog. This allows you to set the default behaviour. This option can be overridden from the Edit Post page

<strong>** Auto Approve imported comments **</strong>

If you trust your friends on Facebook then you're probably quite happy for their comments to automatically get posted as comments on your Wordpress blog. If this option is not set then any imported comments are held in the moderation queue.

Once you've got the options set how you want then save them.

If you exported the wordbook_postcomments table before upgrading then you can now import it back into the database.

There may be times when you you are posting a blog entry and you'd like to do something differently, like NOT publish a post, or change your choice on what you do with comment. So on the Add New and Edit posts page you should now find a Wordbooker Options Override block where you can override several defaults:

[caption id="attachment_737" align="alignnone" width="300" caption="Wordbooker Post options "]<a href="http://blogs.canalplan.org.uk/steve/files/2010/01/wb-post-options.png"><img class="size-medium wp-image-737" title="wb-post options" src="http://blogs.canalplan.org.uk/steve/files/2010/01/wb-post-options-300x79.png" alt="Wordbooker Post options " width="300" height="79" /></a>[/caption]

If you are the administrator of a Facebook Fan page then you'll also be given the option of posting to that page instead of posting to your own wall. At the moment there is a bug in the API which means that posts made to Fan Pages are shown as YOU posting on the Fan Page wall - rather than it looking like the Fan Page has posted the post directly.

PROBLEMS

If you've got problems its probably best to post them on the <a href="http://www.facebook.com/apps/application.php?id=254577506873&amp;ref=nf">Wordbooker Page</a> on Facebook where people can create new threads for each bug/problem and people can easily see if any fixes have been made]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/t0Csu8XRmp5HvjgrE2hN4BDh4I8/0/da"><img src="http://feedads.g.doubleclick.net/~a/t0Csu8XRmp5HvjgrE2hN4BDh4I8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/t0Csu8XRmp5HvjgrE2hN4BDh4I8/1/da"><img src="http://feedads.g.doubleclick.net/~a/t0Csu8XRmp5HvjgrE2hN4BDh4I8/1/di" border="0" ismap="true"></img></a></p>I'd been using the <a title="Link to Wordbook Application on Facebook" href="http://www.facebook.com/apps/application.php?id=3353257731" target="_blank">Wordbook app</a> for quite a bit but I'd always found that it lacked some features that I liked. I've now added these functions and got it doing things how I'd like.

So rather than keep cluttering up the original wordbook application page I've forked by code off totally.

I created a new Facebook application called <a title="Link to Wordbooker Application on Facebook" href="http://www.facebook.com/apps/application.php?id=254577506873" target="_blank">Wordbooker</a> and then created a new plugin called <a title="Link to the Wordbooker extension at Wordpress" href="http://wordpress.org/extend/plugins/wordbooker/" target="_blank">Wordbooker</a> in the Wordpress Extensions site.

<strong><span style="font-size: medium">Upgrading from the Forked Version.</span></strong>

As this is basically a new application its a bit messy as doing a normal removal of the old forked version will remove any record of posts/comments made with the forked version.

If you wish to retain that history then you need to back up the existing wordbook_postcomments table BEFORE you remove the forked version of wordbook.

Go into the options page for Wordbook and reset the configuration for wordbook

From the plugins page de-activate the wordbook plugin.

Delete the wordbook directory from wp-content/plugins

Upload the wordbooker directory into the wp-content/plugins directory

Go into the Plugins page and enable Wordbooker.

Go to the options page for Wordbooker and  it will ask you to get a login key from Facebook and then ask you to grant two extra permissions needed by Wordbooker - these allow Wordbooker to publish to your wall and also to fetch comments from it.

Click on the Save Configuration button.

You can then set up the various options on the option screen:

[caption id="attachment_734" align="alignnone" width="300" caption="Wordbooker Options page"]<a href="http://blogs.canalplan.org.uk/steve/files/2010/01/wb-options.png"><img class="size-medium wp-image-734" title="wb-options" src="http://blogs.canalplan.org.uk/steve/files/2010/01/wb-options-300x158.png" alt="Wordbooker Options page" width="300" height="158" /></a>[/caption]

<strong>** Multiple Facebook account / WordPress account support **</strong>

If you as the blog owner only want it so that WP posts go to your FB account then go into the Options screen and set the default account to be yours, and that should be it, any person using a different WP account to post to your blog will publish those stories to your FB account.

But what if you've got a Family WB where different people would like to post to WP and to their OWN FB accounts. Simply get each of them to login to WP as themselves and configure WB as if they were the only user. Then when all of them have done this go back in as yourself and set the Default account to be you.

On the Edit Post page there is a WordBook Options block which includes a drop down list of the blog you wish to post to, if you want to post to your default blog then you don't need to touch this but if someone wants to post that post to their FB account all they need to do is pick their name from the drop down list before they post.

<strong>** Length of Extract **</strong>
This allows you to change the length of the extract posted to Facebook. The minimum value is 200 and the maximum is 400 (at the moment) with the default being 256 characters. The extract will be trimmed to the nearest full word BELOW this value.

<strong>** Default Publish Post to Facebook **</strong>

This allows you to choose if posts should automatically be posted to Facebook. This option can be overridden from the Edit Post page

<strong>** Post Attribute **</strong>

This allows you to change the attribute line when posts are sent to Facebook. By default this is set to "Posted a new post on their blog". This option can be overridden from the Edit Post page.

<strong>** Republish Post if edited more than x days ago **</strong>

This allows you to control how long it should be before Wordbook considers an edited post to be a "new" post and re-publishes it to Facebook.

<strong>** Override Re-Publication window  **</strong>

This allows to to force all edits to be reposted to Facebook ignoring the republish window. This option can be overridden from the Edit Post page.

<strong>** Update Facebook Status **</strong>
If this option is checked then the title of your blog post and its permalink will be posted to your status, along with the text specified here. This can be overridden from the Edit Post page. NOTE: If this option is Selected then your status is ALWAYS updated, even if you choose NOT to publish your post to Facebook.

<strong>** Import Comments from Facebook for Wordbook Posts  **</strong>

This version of Wordbook supports the importing of comments made on Facebook back into your WordPress blog. This allows you to set the default behaviour. This option can be overridden from the Edit Post page

<strong>** Auto Approve imported comments **</strong>

If you trust your friends on Facebook then you're probably quite happy for their comments to automatically get posted as comments on your Wordpress blog. If this option is not set then any imported comments are held in the moderation queue.

Once you've got the options set how you want then save them.

If you exported the wordbook_postcomments table before upgrading then you can now import it back into the database.

There may be times when you you are posting a blog entry and you'd like to do something differently, like NOT publish a post, or change your choice on what you do with comment. So on the Add New and Edit posts page you should now find a Wordbooker Options Override block where you can override several defaults:

[caption id="attachment_737" align="alignnone" width="300" caption="Wordbooker Post options "]<a href="http://blogs.canalplan.org.uk/steve/files/2010/01/wb-post-options.png"><img class="size-medium wp-image-737" title="wb-post options" src="http://blogs.canalplan.org.uk/steve/files/2010/01/wb-post-options-300x79.png" alt="Wordbooker Post options " width="300" height="79" /></a>[/caption]

If you are the administrator of a Facebook Fan page then you'll also be given the option of posting to that page instead of posting to your own wall. At the moment there is a bug in the API which means that posts made to Fan Pages are shown as YOU posting on the Fan Page wall - rather than it looking like the Fan Page has posted the post directly.

PROBLEMS

If you've got problems its probably best to post them on the <a href="http://www.facebook.com/apps/application.php?id=254577506873&amp;ref=nf">Wordbooker Page</a> on Facebook where people can create new threads for each bug/problem and people can easily see if any fixes have been made<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/3YxMctJ_oDg" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2010/01/02/wordpress-and-facebook-integration/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2010/01/02/wordpress-and-facebook-integration/</feedburner:origLink></item>
						<item>
				<title>The Cast List of White Christmas</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/xrYsyGRBFhk/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/12/24/the-cast-list-of-white-christmas/#comments</comments>
				<pubDate>Thu, 24 Dec 2009 13:38:21 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/12/24/the-cast-list-of-white-christmas/</guid>
                <description><![CDATA[Emma Dreaming
Arthur White
Chris Muss
Jess Likedy
Juan Sy
Hugh Sterno

Wendy Treetops-Glissen
Ann Chilled-Wren
Liz Anne
“Two Ears” Laybelle
Cindy Snow

Emma Dreaming
Arthur White
Chris Musswit
Avery Criss
Miss Carr
Dai Wright

Mayor Dazeby
Mary-Ann Bright
Anna-May Hall-York-Rhys
Mrs B White

Totally NOT my work, all credit goes to Graham Garden, Bill Oddie and Tim Brooke-Taylor for writing this and putting it in "<em>The Making of The Goodies Distaster Movie</em>".]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/sYVUPK_zfGKZkfR1SfbxysSY7ds/0/da"><img src="http://feedads.g.doubleclick.net/~a/sYVUPK_zfGKZkfR1SfbxysSY7ds/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/sYVUPK_zfGKZkfR1SfbxysSY7ds/1/da"><img src="http://feedads.g.doubleclick.net/~a/sYVUPK_zfGKZkfR1SfbxysSY7ds/1/di" border="0" ismap="true"></img></a></p>Emma Dreaming
Arthur White
Chris Muss
Jess Likedy
Juan Sy
Hugh Sterno

Wendy Treetops-Glissen
Ann Chilled-Wren
Liz Anne
“Two Ears” Laybelle
Cindy Snow

Emma Dreaming
Arthur White
Chris Musswit
Avery Criss
Miss Carr
Dai Wright

Mayor Dazeby
Mary-Ann Bright
Anna-May Hall-York-Rhys
Mrs B White

Totally NOT my work, all credit goes to Graham Garden, Bill Oddie and Tim Brooke-Taylor for writing this and putting it in "<em>The Making of The Goodies Distaster Movie</em>".<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/xrYsyGRBFhk" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/12/24/the-cast-list-of-white-christmas/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/12/24/the-cast-list-of-white-christmas/</feedburner:origLink></item>
						<item>
				<title>A Thanksgiving Wedding</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/_jlDvHU4RiU/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/12/01/a-thanksgiving-wedding/#comments</comments>
				<pubDate>Tue, 01 Dec 2009 18:29:40 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/12/01/a-thanksgiving-wedding/</guid>
                <description><![CDATA[So what did you do on the Saturday following Thanksgiving on Thursday and the madness of "Black Friday"? Did you take it easy and watch some TV, or did you venture out to do some shopping hoping that things would be a little quieter.

Or did you go to a wedding?

Rick and Jill's wedding was one of the reasons we'd flown back to Maine and with it being on the Thanksgiving weekend it all worked out quite well.

Having recovered from too much turkey on Thursday we all gathered at the church on Friday evening to have a rehearsal which went quite smoothly which I suppose is a good thing, and then we all went over to the <a title="link to the Ground Round website" href="http://www.groundroundme.com/" target="_blank">Ground Round</a> for the rehearsal supper where I think we almost ate too much food again.

Saturday morning seemed to roll round really quickly and Kathy headed out to get her hair done, having got her nails done on Friday afternoon in the middle of the Black Friday madness. Then the Groom's party descended on the house to get ready which was slightly less chaotic than when Jen got married the other year, but not by much.

There had been an earlier wedding at the church but by the time we got there there was no sign of them and it wasn't long before wedding guests started turning up and the ceremony started right on time.

It was a pretty good ceremony with some good readings and the deacon talked well and made everyone feel welcome and relaxed, and even made a joke or two.

There was one very funny moment during the service when Rick and Jill went up to light the unity candle from the two side candles and they'd lit it and were walking back and it went out, so the deacon called them back and they tried to re-light it but it just didn't want to know. After a little bit of work, and two tapers which were really starting to flare up, they got it lit and made their way back to their places and the ceremony continued.

<img src="http://blogs.canalplan.org.uk/steve/files/2009/12/13742_1291940983817_1389037839_836473_2130235_n.jpg" alt="13742 1291940983817 1389037839 836473 2130235 n" width="450" height="299" />

I got caught out by the Roman Catholic version of The Lords Prayer which is several lines shorter at the end, and it seems that it caught everyone else who wasn't RC out as well.

After the service was over and photos were taken we all piled into various cars and headed across town to the Augusta Civic Center where the reception was being held. They'd even put a message on the electric notice board at the Civic Center so anyone driving past it would know.

<img src="http://blogs.canalplan.org.uk/steve/files/2009/12/13742_1291932823613_1389037839_836464_5532964_n-1.jpg" alt="13742 1291932823613 1389037839 836464 5532964 n" width="450" height="337" />

The reception was being held in a function room in the North wing of the Center and there was a craft fayre being held in the main auditorium which some of us joked about crashing but  I think the arrival of a lot of people in matching tuxedos and waistcoats might have thrown them off a bit.

It was a great reception and everyone seemed to have a good time. So to finish off this blog here is a picture of the happy couple

<img src="http://blogs.canalplan.org.uk/steve/files/2009/12/13742_1291977184722_1389037839_836631_633757_n.jpg" alt="13742 1291977184722 1389037839 836631 633757 n" width="450" height="299" />]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/xxXuORKjgoZQsqDhDgwA9T3ftW4/0/da"><img src="http://feedads.g.doubleclick.net/~a/xxXuORKjgoZQsqDhDgwA9T3ftW4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/xxXuORKjgoZQsqDhDgwA9T3ftW4/1/da"><img src="http://feedads.g.doubleclick.net/~a/xxXuORKjgoZQsqDhDgwA9T3ftW4/1/di" border="0" ismap="true"></img></a></p>So what did you do on the Saturday following Thanksgiving on Thursday and the madness of "Black Friday"? Did you take it easy and watch some TV, or did you venture out to do some shopping hoping that things would be a little quieter.

Or did you go to a wedding?

Rick and Jill's wedding was one of the reasons we'd flown back to Maine and with it being on the Thanksgiving weekend it all worked out quite well.

Having recovered from too much turkey on Thursday we all gathered at the church on Friday evening to have a rehearsal which went quite smoothly which I suppose is a good thing, and then we all went over to the <a title="link to the Ground Round website" href="http://www.groundroundme.com/" target="_blank">Ground Round</a> for the rehearsal supper where I think we almost ate too much food again.

Saturday morning seemed to roll round really quickly and Kathy headed out to get her hair done, having got her nails done on Friday afternoon in the middle of the Black Friday madness. Then the Groom's party descended on the house to get ready which was slightly less chaotic than when Jen got married the other year, but not by much.

There had been an earlier wedding at the church but by the time we got there there was no sign of them and it wasn't long before wedding guests started turning up and the ceremony started right on time.

It was a pretty good ceremony with some good readings and the deacon talked well and made everyone feel welcome and relaxed, and even made a joke or two.

There was one very funny moment during the service when Rick and Jill went up to light the unity candle from the two side candles and they'd lit it and were walking back and it went out, so the deacon called them back and they tried to re-light it but it just didn't want to know. After a little bit of work, and two tapers which were really starting to flare up, they got it lit and made their way back to their places and the ceremony continued.

<img src="http://blogs.canalplan.org.uk/steve/files/2009/12/13742_1291940983817_1389037839_836473_2130235_n.jpg" alt="13742 1291940983817 1389037839 836473 2130235 n" width="450" height="299" />

I got caught out by the Roman Catholic version of The Lords Prayer which is several lines shorter at the end, and it seems that it caught everyone else who wasn't RC out as well.

After the service was over and photos were taken we all piled into various cars and headed across town to the Augusta Civic Center where the reception was being held. They'd even put a message on the electric notice board at the Civic Center so anyone driving past it would know.

<img src="http://blogs.canalplan.org.uk/steve/files/2009/12/13742_1291932823613_1389037839_836464_5532964_n-1.jpg" alt="13742 1291932823613 1389037839 836464 5532964 n" width="450" height="337" />

The reception was being held in a function room in the North wing of the Center and there was a craft fayre being held in the main auditorium which some of us joked about crashing but  I think the arrival of a lot of people in matching tuxedos and waistcoats might have thrown them off a bit.

It was a great reception and everyone seemed to have a good time. So to finish off this blog here is a picture of the happy couple

<img src="http://blogs.canalplan.org.uk/steve/files/2009/12/13742_1291977184722_1389037839_836631_633757_n.jpg" alt="13742 1291977184722 1389037839 836631 633757 n" width="450" height="299" /><img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/_jlDvHU4RiU" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/12/01/a-thanksgiving-wedding/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/12/01/a-thanksgiving-wedding/</feedburner:origLink></item>
						<item>
				<title>American Customs</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/A0kZQLSzfXo/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/11/26/american-customs/#comments</comments>
				<pubDate>Thu, 26 Nov 2009 20:52:08 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/11/26/american-customs/</guid>
                <description><![CDATA[<p>On Monday after returning from our weekend away in Kennebunkport I went to my first basketball game. It was a game between the Maine Redclaws and the Springfield Armor at the Augusta Civic Center.</p>
<p>I had no real idea of what to expect. I'd seen some games on TV, including a couple over at Sue and Jeff's but watching top flight pro teams on TV is very different to seing a pretty new team in the D league. Probably like watching Arsenal v Chelsea on TV and then going to watch Cheltenham v Burton Albion.</p>
<p>I think what struck me most was how disjointed the whole thing felt. There were mad bursts of action with players running back and forth along the full length of the court and then there were whole periods of nothing going on with timeouts and penalty shots, and sometimes those penalty shots seemed to take forever to be taken. Of course with all the timeouts and everything else it's surprising how long 48 minutes of play can be stretched out to, and having a ref who seeemed to love the sound of his own whistle and his own voice probably didn't help, and the crowd of just over 3000 people didn't think he was doing a very good job.</p>
<p>Today was of course, Thanksgiving, so that meant a lot of good food and family time with Kathy's family, and everyone ate too much, and that was before we started on the various pies for dessert.</p>
<p>Now everyone is just sitting round relaxing and trying not to fall asleep, and talking about plans for Black Friday, and working on wedding programs for this weekend.</p>]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/vsWTF9FfaVgBzhyZdubw1KR7Aa0/0/da"><img src="http://feedads.g.doubleclick.net/~a/vsWTF9FfaVgBzhyZdubw1KR7Aa0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vsWTF9FfaVgBzhyZdubw1KR7Aa0/1/da"><img src="http://feedads.g.doubleclick.net/~a/vsWTF9FfaVgBzhyZdubw1KR7Aa0/1/di" border="0" ismap="true"></img></a></p><p>On Monday after returning from our weekend away in Kennebunkport I went to my first basketball game. It was a game between the Maine Redclaws and the Springfield Armor at the Augusta Civic Center.</p>
<p>I had no real idea of what to expect. I'd seen some games on TV, including a couple over at Sue and Jeff's but watching top flight pro teams on TV is very different to seing a pretty new team in the D league. Probably like watching Arsenal v Chelsea on TV and then going to watch Cheltenham v Burton Albion.</p>
<p>I think what struck me most was how disjointed the whole thing felt. There were mad bursts of action with players running back and forth along the full length of the court and then there were whole periods of nothing going on with timeouts and penalty shots, and sometimes those penalty shots seemed to take forever to be taken. Of course with all the timeouts and everything else it's surprising how long 48 minutes of play can be stretched out to, and having a ref who seeemed to love the sound of his own whistle and his own voice probably didn't help, and the crowd of just over 3000 people didn't think he was doing a very good job.</p>
<p>Today was of course, Thanksgiving, so that meant a lot of good food and family time with Kathy's family, and everyone ate too much, and that was before we started on the various pies for dessert.</p>
<p>Now everyone is just sitting round relaxing and trying not to fall asleep, and talking about plans for Black Friday, and working on wedding programs for this weekend.</p><img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/A0kZQLSzfXo" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/11/26/american-customs/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/11/26/american-customs/</feedburner:origLink></item>
						<item>
				<title>What's in a name?</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/N9rvFkgoUKs/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/11/24/whats-in-a-name/#comments</comments>
				<pubDate>Tue, 24 Nov 2009 22:08:33 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/11/24/whats-in-a-name/</guid>
                <description><![CDATA[There's just something about the names of places in Maine: Perkin's Cove, Nubble Rock, Cape Neddick, Cape Porpoise, Goat Island..

They sound like places out of a pirate story, but they're all very real and we didn't see a single pirate at all which was a great pity.

We had a very enjoyable and relaxing weekend down at Kennebunkport staying at the <a href="http://www.nonantumresort.com/">Nonantum Resort</a> . Although it was a bit odd when we came back on Sunday and found that the main part of the building was in complete darkness and that there were only 4 cars in the <a href="http://www.nonantumresort.com/Lodging/portsidelodge.html">Portside Lodge</a> parking lot.  I can't remember when I was last in a pretty much empty hotel, and we were torn between running round the place causing havoc or holding a ghost hunt - but I suspect the main hotel building is the place to do that.... even if its a bit a long hike for Parasoc!

Some of the other big hotels were also locked up tight,  "The Colony" was all in darkness apart from some outside lights, and there was no indication of any caretaker there for the winter, so at least there wasn't going to be a Shining style incident, even if the hotel did look similar to The Overlook in some aspects. But we all agreed that being the over-winter caretaker in a hotel would actually be quite interesting and fun. So if you own a Maine Coastal Hotel and want some winter housekeepers........

We ate a couple of times at <a href="http://www.mainediner.com/">The Maine Diner</a> which does really good food in a very uncomplicated way, in very simple but comfortable surroundings. So if you're ever on Route One near Wells then I really recommend pulling in and eating there.

I nearly called this post "Goodbye <a href="http://www.seacoastnh.com/Travel/Scenic_Walks/Marginal_Way/">Marginal way</a>" but decided not to (which I'm sure is something you're really grateful about). We'd been for a walk along Marginal Way after going down to Cape Neddick. The last time we'd been down to Cape Neddick the weather had been rather bad and getting out of the car was not something you really wanted to do, but this time the weather was a lot better and there were quite a few people there. There were quite a few people on Marginal Way too, taking advantage of the good weather to enjoy an afternoon walk along the coast and we took our time and took in the scenery and the sounds and Jeff and I didn't even get splashed once in all our rock scrambling.]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/vaFjW9Zzb-C_OTHpgB7LTuHrATY/0/da"><img src="http://feedads.g.doubleclick.net/~a/vaFjW9Zzb-C_OTHpgB7LTuHrATY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/vaFjW9Zzb-C_OTHpgB7LTuHrATY/1/da"><img src="http://feedads.g.doubleclick.net/~a/vaFjW9Zzb-C_OTHpgB7LTuHrATY/1/di" border="0" ismap="true"></img></a></p>There's just something about the names of places in Maine: Perkin's Cove, Nubble Rock, Cape Neddick, Cape Porpoise, Goat Island..

They sound like places out of a pirate story, but they're all very real and we didn't see a single pirate at all which was a great pity.

We had a very enjoyable and relaxing weekend down at Kennebunkport staying at the <a href="http://www.nonantumresort.com/">Nonantum Resort</a> . Although it was a bit odd when we came back on Sunday and found that the main part of the building was in complete darkness and that there were only 4 cars in the <a href="http://www.nonantumresort.com/Lodging/portsidelodge.html">Portside Lodge</a> parking lot.  I can't remember when I was last in a pretty much empty hotel, and we were torn between running round the place causing havoc or holding a ghost hunt - but I suspect the main hotel building is the place to do that.... even if its a bit a long hike for Parasoc!

Some of the other big hotels were also locked up tight,  "The Colony" was all in darkness apart from some outside lights, and there was no indication of any caretaker there for the winter, so at least there wasn't going to be a Shining style incident, even if the hotel did look similar to The Overlook in some aspects. But we all agreed that being the over-winter caretaker in a hotel would actually be quite interesting and fun. So if you own a Maine Coastal Hotel and want some winter housekeepers........

We ate a couple of times at <a href="http://www.mainediner.com/">The Maine Diner</a> which does really good food in a very uncomplicated way, in very simple but comfortable surroundings. So if you're ever on Route One near Wells then I really recommend pulling in and eating there.

I nearly called this post "Goodbye <a href="http://www.seacoastnh.com/Travel/Scenic_Walks/Marginal_Way/">Marginal way</a>" but decided not to (which I'm sure is something you're really grateful about). We'd been for a walk along Marginal Way after going down to Cape Neddick. The last time we'd been down to Cape Neddick the weather had been rather bad and getting out of the car was not something you really wanted to do, but this time the weather was a lot better and there were quite a few people there. There were quite a few people on Marginal Way too, taking advantage of the good weather to enjoy an afternoon walk along the coast and we took our time and took in the scenery and the sounds and Jeff and I didn't even get splashed once in all our rock scrambling.<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/N9rvFkgoUKs" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/11/24/whats-in-a-name/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/11/24/whats-in-a-name/</feedburner:origLink></item>
						<item>
				<title>The Rain in Maine...</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/5L1fv7hkjhY/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/11/16/the-rain-in-maine/#comments</comments>
				<pubDate>Mon, 16 Nov 2009 02:56:18 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/11/16/the-rain-in-maine/</guid>
                <description><![CDATA[...was mainly on the Interstate.

The weather was pretty lousy when we drove down to Heathrow on Friday night and we took it steady on the M4 but several lunatics in BMW's steamed past us at speeds that must have been in excess of 90 mph. We stopped at Reading services for a coffee and loo break before heading back out and getting to the hotel at a not unreasonable hour.

Saturday morning the weather wasn't much better and the hotel hoppa took us to Terminal 5 through some pretty lousy weather and flooded roads. The bus drive nearly drove into the back of a broken down car, and I think he was the only person who hadn't seen it. 

We left Heathrow about 30 minutes late in very heavy wind and rain and the take-off was pretty shaky and the pilot didn't waste any time in getting above the storm and most of the flight was quite smooth, apart from the annoying kid in the seat behind me who kept kicking and hitting the seat and whose parents didn't seem to give a toss. I'd like it if when you book airline seats and they ask if you have special dietary requirements if you could also specify that you don't want to sit next to, directly in front of, or behind, snotty little brats.

The captain told us that the weather in Boston was pretty much the same as in London and he was right, it was muggy and raining and despite us leaving Heathrow late we actually landed a little early. As we were walking away from the plane I noticed that a lot of the stands were empty and that there hardly seemed to be any planes around. The immigration hall was pretty much deserted and we were only standing in line for a couple of minutes. The immigration officer told us that it was "just a lull" but when we got down into baggage claim the place was pretty much deserted with no other carousels running and our luggage came out pretty quickly.

Then the fun began. We'd brought two bottles of alcohol into the country and the immigration officer asked us if we'd got foodstuffs etc. We said no and he scribbled things on our customs form. After we'd collected our luggage and we headed towards custom we were intercepted and the form looked at and the same questions asked and our form marked again. We were told to go over to one side where they asked us the same questions about foodstuffs etc. and then we had to put all our bags through a scanner.

But even with that we were still outside in a record time. It felt odd to be in Boston in daylight as we usually seem to arrive there late in the afternoon. The bus turned up and we got on and soon we were heading North.

The rain, which had been consistent but light turned heavier and heavier and it wasn't long before the bus was the fastest thing on the road. I'm not sure how the driver could see where we were going but we got to the bus station in Portland about 15 minutes ahead of schedule. Our cases were dragged off the bus and one of them was a little damp, which given the weather was hardly surprising.

The rain backed off a little bit but then came on a lot harder just in time for Rick and Jill to turn up to collect us.

The rain got heavier and heavier and the drive north wasn't much fun and there was a lot of standing water on the road. We'd got wet getting the suitcases into the back of the truck and we'd not actually dried out much by the time we had to get out and unload the cases again. They said that it did just over 2.5 inches of rain but I guess we must have been travelling with the heaviest part of the storm because it felt like a lot more.

Everything was a little wet when we unpacked it but we soon got everything dried off and the weather has been pretty good since then.
]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/DYWroEmvbDxsm-tXO9eDtp-y7Tg/0/da"><img src="http://feedads.g.doubleclick.net/~a/DYWroEmvbDxsm-tXO9eDtp-y7Tg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/DYWroEmvbDxsm-tXO9eDtp-y7Tg/1/da"><img src="http://feedads.g.doubleclick.net/~a/DYWroEmvbDxsm-tXO9eDtp-y7Tg/1/di" border="0" ismap="true"></img></a></p>...was mainly on the Interstate.

The weather was pretty lousy when we drove down to Heathrow on Friday night and we took it steady on the M4 but several lunatics in BMW's steamed past us at speeds that must have been in excess of 90 mph. We stopped at Reading services for a coffee and loo break before heading back out and getting to the hotel at a not unreasonable hour.

Saturday morning the weather wasn't much better and the hotel hoppa took us to Terminal 5 through some pretty lousy weather and flooded roads. The bus drive nearly drove into the back of a broken down car, and I think he was the only person who hadn't seen it. 

We left Heathrow about 30 minutes late in very heavy wind and rain and the take-off was pretty shaky and the pilot didn't waste any time in getting above the storm and most of the flight was quite smooth, apart from the annoying kid in the seat behind me who kept kicking and hitting the seat and whose parents didn't seem to give a toss. I'd like it if when you book airline seats and they ask if you have special dietary requirements if you could also specify that you don't want to sit next to, directly in front of, or behind, snotty little brats.

The captain told us that the weather in Boston was pretty much the same as in London and he was right, it was muggy and raining and despite us leaving Heathrow late we actually landed a little early. As we were walking away from the plane I noticed that a lot of the stands were empty and that there hardly seemed to be any planes around. The immigration hall was pretty much deserted and we were only standing in line for a couple of minutes. The immigration officer told us that it was "just a lull" but when we got down into baggage claim the place was pretty much deserted with no other carousels running and our luggage came out pretty quickly.

Then the fun began. We'd brought two bottles of alcohol into the country and the immigration officer asked us if we'd got foodstuffs etc. We said no and he scribbled things on our customs form. After we'd collected our luggage and we headed towards custom we were intercepted and the form looked at and the same questions asked and our form marked again. We were told to go over to one side where they asked us the same questions about foodstuffs etc. and then we had to put all our bags through a scanner.

But even with that we were still outside in a record time. It felt odd to be in Boston in daylight as we usually seem to arrive there late in the afternoon. The bus turned up and we got on and soon we were heading North.

The rain, which had been consistent but light turned heavier and heavier and it wasn't long before the bus was the fastest thing on the road. I'm not sure how the driver could see where we were going but we got to the bus station in Portland about 15 minutes ahead of schedule. Our cases were dragged off the bus and one of them was a little damp, which given the weather was hardly surprising.

The rain backed off a little bit but then came on a lot harder just in time for Rick and Jill to turn up to collect us.

The rain got heavier and heavier and the drive north wasn't much fun and there was a lot of standing water on the road. We'd got wet getting the suitcases into the back of the truck and we'd not actually dried out much by the time we had to get out and unload the cases again. They said that it did just over 2.5 inches of rain but I guess we must have been travelling with the heaviest part of the storm because it felt like a lot more.

Everything was a little wet when we unpacked it but we soon got everything dried off and the weather has been pretty good since then.
<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/5L1fv7hkjhY" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/11/16/the-rain-in-maine/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/11/16/the-rain-in-maine/</feedburner:origLink></item>
						<item>
				<title>Look out Maine.... here we come!</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/zsr4ieJeWes/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/11/12/look-out-maine-here-we-come-2/#comments</comments>
				<pubDate>Thu, 12 Nov 2009 14:21:59 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/11/12/look-out-maine-here-we-come-2/</guid>
                <description><![CDATA[Well not until some time on Saturday but we're on the taxi-way.

The house is pretty much cleaned up and de-fluffed and the parents will be here later this afternoon to house and cat sit whilst we're away.

Cameras are just about packed, and I'm sort of half done on my packing, which I suppose I should finish off so that I'll be ready to drive us down to Heathrow on Friday night. We've got a good deal on a hotel room with parking, and its a lot less stressful driving down the night before than getting up at something like 4 am to get down to get the coach from the bus station over to Heathrow when you always end up clock watching and every single slow down turns into a minor panic about getting there on time.

We're flying with BA from Terminal 5, so it will be interesting to see if its really as impressive as they claimed and as it looks on TV. We're actually arriving in Boston at a sensible time and we'll see if my electronic visa paperwork has actually made it through the system: they say you don't need to keep a copy of the confirmation that its valid or take it with you, but we're not risking it. Then its just a matter of hopping on the Concord bus service to Portland where we'll be picked up and taken up to Kathy's mums.

We've not got a lot planned: A weekend in Kennebunkport with friends, Thanksgiving with Kathy's family, and hopefully just a lot of time relaxing, well relaxing for Kathy, I'm hoping that I just wont be sitting round the house all day, I do enough of that at home.

Of course, I nearly forgot : there's a wedding to go to as well  :lol:  Rick and Jill are tying the knot the Thanksgiving weekend. Its been a far from easy year for both of them but things seem to be getting better and I'm sure everyone is looking forward to it and all Jill's planning will all come together.

Weatherwise : well its Maine so everything from bright sunshine, through rain to frost and snow, so we've packed hats and gloves and a mixture of clothes, but I don't think I'll bother packing the sunscreen or my shorts... but now I've said that  :lol:

Right, that's enough for now, I think I probably need to go and finish off the vacuuming!]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/cVIEgO_BLC-x1QKj6autduXWxIg/0/da"><img src="http://feedads.g.doubleclick.net/~a/cVIEgO_BLC-x1QKj6autduXWxIg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/cVIEgO_BLC-x1QKj6autduXWxIg/1/da"><img src="http://feedads.g.doubleclick.net/~a/cVIEgO_BLC-x1QKj6autduXWxIg/1/di" border="0" ismap="true"></img></a></p>Well not until some time on Saturday but we're on the taxi-way.

The house is pretty much cleaned up and de-fluffed and the parents will be here later this afternoon to house and cat sit whilst we're away.

Cameras are just about packed, and I'm sort of half done on my packing, which I suppose I should finish off so that I'll be ready to drive us down to Heathrow on Friday night. We've got a good deal on a hotel room with parking, and its a lot less stressful driving down the night before than getting up at something like 4 am to get down to get the coach from the bus station over to Heathrow when you always end up clock watching and every single slow down turns into a minor panic about getting there on time.

We're flying with BA from Terminal 5, so it will be interesting to see if its really as impressive as they claimed and as it looks on TV. We're actually arriving in Boston at a sensible time and we'll see if my electronic visa paperwork has actually made it through the system: they say you don't need to keep a copy of the confirmation that its valid or take it with you, but we're not risking it. Then its just a matter of hopping on the Concord bus service to Portland where we'll be picked up and taken up to Kathy's mums.

We've not got a lot planned: A weekend in Kennebunkport with friends, Thanksgiving with Kathy's family, and hopefully just a lot of time relaxing, well relaxing for Kathy, I'm hoping that I just wont be sitting round the house all day, I do enough of that at home.

Of course, I nearly forgot : there's a wedding to go to as well  :lol:  Rick and Jill are tying the knot the Thanksgiving weekend. Its been a far from easy year for both of them but things seem to be getting better and I'm sure everyone is looking forward to it and all Jill's planning will all come together.

Weatherwise : well its Maine so everything from bright sunshine, through rain to frost and snow, so we've packed hats and gloves and a mixture of clothes, but I don't think I'll bother packing the sunscreen or my shorts... but now I've said that  :lol:

Right, that's enough for now, I think I probably need to go and finish off the vacuuming!<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/zsr4ieJeWes" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/11/12/look-out-maine-here-we-come-2/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/11/12/look-out-maine-here-we-come-2/</feedburner:origLink></item>
						<item>
				<title>Wordpress and Facebook Part five</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/-7IWRxPFNTE/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/11/10/wordpress-and-facebook-part-five/#comments</comments>
				<pubDate>Tue, 10 Nov 2009 18:45:16 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/11/10/wordpress-and-facebook-part-five/</guid>
                <description><![CDATA[Well I've been hard at work on my forked version of the <a href="http://wordpress.org/extend/plugins/wordbook/">Wordbook plugin </a>which links your own hosted <a href="http://wordpress.org/">WordPress</a> Blog with your <a href="http://www.facebook.com">Facebook </a>account. Oh and it also works with <a href="http://mu.wordpress.org/">WordPress MU</a> too.

Its now really reached a point where I'm quite happy with it.

So what does it now support?

<strong><span style="font-size: medium">Multiple Facebook account / WordPress account support</span></strong>

If you have multiple users of your blog the old version wouldn't post to YOUR Facebook account. It would post to THEIRS, if they had set it up. This version of the plugin now handles multiple WP Accounts. If you as the blog owner only want it so that WP posts go to your FB account then go into the Options screen and set the default account to be yours, and that should be it, any person using a different WP account to post to your blog will publish those stories to your FB account.

But what if you've got a Family WordPress where different people would like to post to WP and to their OWN FB accounts. Simply get each of them to login to WP as themselves and configure WB as if they were the only user. Then when all of them have done this go back in as yourself and set the Default account to be you.

On the Edit Post page there is a WordBook Options block which includes a drop down list of the blog you wish to post to, if you want to post to your default blog then you don't need to touch this but if someone wants to post that post to their FB account all they need to do is pick their name from the drop down list before they post.

<strong><span style="font-size: medium">Length of Extract </span></strong>

This allows you to change the length of the extract posted to Facebook. The minimum value is 200 and the maximum is 400 (at the moment) with the default being 256 characters. The extract will be trimmed to the nearest full word BELOW this value.

<strong><span style="font-size: medium">Default Publish Post to Facebook</span></strong>

This allows you to choose if posts should automatically be posted to Facebook. This option can be overridden from the Edit Post page

<strong><span style="font-size: medium">Post Attribute</span></strong>

This allows you to change the attribute line when posts are sent to Facebook. By default this is set to "Posted a new post on their blog". This option can be overridden from the Edit Post page.

<strong><span style="font-size: medium">Republish Post if edited more than <em>x</em> days ago</span></strong>

This allows you to control how long it should be before Wordbook considers an edited post to be a "new" post and re-publishes it to Facebook.

<strong><span style="font-size: medium">Override Re-Publication window</span></strong>

This allows to to force all edits to be reposted to Facebook ignoring the republish window. This option can be overridden from the Edit Post page.

<strong><span style="font-size: medium"> Update Facebook Status </span></strong>

If this option is checked then the title of your blog post and its permalink will be posted to your status, along with the text specified here. This can be overridden from the Edit Post page. NOTE: If this option is Selected then your status is ALWAYS updated, even if you choose NOT to publish your post to Facebook.

<strong><span style="font-size: medium">Import Comments from Facebook for Wordbook Posts</span></strong>

This version of Wordbook supports the importing of comments made on Facebook back into your WordPress blog. This allows you to set the default behaviour. This option can be overridden from the Edit Post page.

<strong><span style="font-size: medium">Auto Approve imported comments</span></strong>

If you trust your friends on Facebook then you're probably quite happy for their comments to automatically get posted as comments on your Wordpress blog. If this option is not set then any imported comments are held in the moderation queue.

<span style="font-size: medium"><strong>Posting using XMLRPC clients</strong>
</span>

Posts published to your WordPress account using XMLRPC clients will now also publish to Facebook - if the default option of posting to Facebook is set. Posts made via this method will also pick up the default target Facebook account, the default post attribute line, and the Update Status options.

<strong><span style="font-size: medium">
Upgrading from the stock version obtained from the Wordpress plugins repository:</span></strong>

* You need to de-activate the old plug in first.
* Then DELETE the wordbook folder from wp-content/plugins and then upload the new version. DON'T just copy the new files up.
* Re-activate the plugin
* Go to the Options page for the plugin and you can set all the new wizzy options. If you want to pull comments from your Facebook account you’ll need to grant the plugin permission to read from your stream. If you don’t grant this permission then you can’t pull comments, and I’ve no idea what my code will do if it tries to do that because I didn’t test it! So you have been warned!

<strong><span style="font-size: medium">Debugging</span></strong>

The only place I’ve put any real debugging in is in the cron job code because its very hard to actually work out if its working if there are no comments to pull. Debugging for that can be enabled by editing two lines in wordbook_cron.php:

define (’DEBUG’, false); which you change to true

and

$debug_file=’/tmp/wordbook_’.$table_prefix.’debug’; which you may need to change if you want to change the output directory.

So where is it I here you ask?

Right Here:

<a href='http://blogs.canalplan.org.uk/steve/files/2009/11/wordbook_1.5.zip'>wordbook1.5</a>]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/zPlrgMpLrXSYy9a6vDe0h5wh1q8/0/da"><img src="http://feedads.g.doubleclick.net/~a/zPlrgMpLrXSYy9a6vDe0h5wh1q8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/zPlrgMpLrXSYy9a6vDe0h5wh1q8/1/da"><img src="http://feedads.g.doubleclick.net/~a/zPlrgMpLrXSYy9a6vDe0h5wh1q8/1/di" border="0" ismap="true"></img></a></p>Well I've been hard at work on my forked version of the <a href="http://wordpress.org/extend/plugins/wordbook/">Wordbook plugin </a>which links your own hosted <a href="http://wordpress.org/">WordPress</a> Blog with your <a href="http://www.facebook.com">Facebook </a>account. Oh and it also works with <a href="http://mu.wordpress.org/">WordPress MU</a> too.

Its now really reached a point where I'm quite happy with it.

So what does it now support?

<strong><span style="font-size: medium">Multiple Facebook account / WordPress account support</span></strong>

If you have multiple users of your blog the old version wouldn't post to YOUR Facebook account. It would post to THEIRS, if they had set it up. This version of the plugin now handles multiple WP Accounts. If you as the blog owner only want it so that WP posts go to your FB account then go into the Options screen and set the default account to be yours, and that should be it, any person using a different WP account to post to your blog will publish those stories to your FB account.

But what if you've got a Family WordPress where different people would like to post to WP and to their OWN FB accounts. Simply get each of them to login to WP as themselves and configure WB as if they were the only user. Then when all of them have done this go back in as yourself and set the Default account to be you.

On the Edit Post page there is a WordBook Options block which includes a drop down list of the blog you wish to post to, if you want to post to your default blog then you don't need to touch this but if someone wants to post that post to their FB account all they need to do is pick their name from the drop down list before they post.

<strong><span style="font-size: medium">Length of Extract </span></strong>

This allows you to change the length of the extract posted to Facebook. The minimum value is 200 and the maximum is 400 (at the moment) with the default being 256 characters. The extract will be trimmed to the nearest full word BELOW this value.

<strong><span style="font-size: medium">Default Publish Post to Facebook</span></strong>

This allows you to choose if posts should automatically be posted to Facebook. This option can be overridden from the Edit Post page

<strong><span style="font-size: medium">Post Attribute</span></strong>

This allows you to change the attribute line when posts are sent to Facebook. By default this is set to "Posted a new post on their blog". This option can be overridden from the Edit Post page.

<strong><span style="font-size: medium">Republish Post if edited more than <em>x</em> days ago</span></strong>

This allows you to control how long it should be before Wordbook considers an edited post to be a "new" post and re-publishes it to Facebook.

<strong><span style="font-size: medium">Override Re-Publication window</span></strong>

This allows to to force all edits to be reposted to Facebook ignoring the republish window. This option can be overridden from the Edit Post page.

<strong><span style="font-size: medium"> Update Facebook Status </span></strong>

If this option is checked then the title of your blog post and its permalink will be posted to your status, along with the text specified here. This can be overridden from the Edit Post page. NOTE: If this option is Selected then your status is ALWAYS updated, even if you choose NOT to publish your post to Facebook.

<strong><span style="font-size: medium">Import Comments from Facebook for Wordbook Posts</span></strong>

This version of Wordbook supports the importing of comments made on Facebook back into your WordPress blog. This allows you to set the default behaviour. This option can be overridden from the Edit Post page.

<strong><span style="font-size: medium">Auto Approve imported comments</span></strong>

If you trust your friends on Facebook then you're probably quite happy for their comments to automatically get posted as comments on your Wordpress blog. If this option is not set then any imported comments are held in the moderation queue.

<span style="font-size: medium"><strong>Posting using XMLRPC clients</strong>
</span>

Posts published to your WordPress account using XMLRPC clients will now also publish to Facebook - if the default option of posting to Facebook is set. Posts made via this method will also pick up the default target Facebook account, the default post attribute line, and the Update Status options.

<strong><span style="font-size: medium">
Upgrading from the stock version obtained from the Wordpress plugins repository:</span></strong>

* You need to de-activate the old plug in first.
* Then DELETE the wordbook folder from wp-content/plugins and then upload the new version. DON'T just copy the new files up.
* Re-activate the plugin
* Go to the Options page for the plugin and you can set all the new wizzy options. If you want to pull comments from your Facebook account you’ll need to grant the plugin permission to read from your stream. If you don’t grant this permission then you can’t pull comments, and I’ve no idea what my code will do if it tries to do that because I didn’t test it! So you have been warned!

<strong><span style="font-size: medium">Debugging</span></strong>

The only place I’ve put any real debugging in is in the cron job code because its very hard to actually work out if its working if there are no comments to pull. Debugging for that can be enabled by editing two lines in wordbook_cron.php:

define (’DEBUG’, false); which you change to true

and

$debug_file=’/tmp/wordbook_’.$table_prefix.’debug’; which you may need to change if you want to change the output directory.

So where is it I here you ask?

Right Here:

<a href='http://blogs.canalplan.org.uk/steve/files/2009/11/wordbook_1.5.zip'>wordbook1.5</a><img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/-7IWRxPFNTE" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/11/10/wordpress-and-facebook-part-five/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/11/10/wordpress-and-facebook-part-five/</feedburner:origLink></item>
						<item>
				<title>Wordpress and Facebook - Part 4</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/bm2DBqd1qWs/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/10/28/wordpress-and-facebook-part-4/#comments</comments>
				<pubDate>Wed, 28 Oct 2009 16:16:41 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/10/28/wordpress-and-facebook-part-4/</guid>
                <description><![CDATA[Back in<a href="http://blogs.canalplan.org.uk/steve/2009/08/11/wordpress-and-facebook-part-3/"> August I wrote </a>about the <a href="http://wordpress.org/extend/plugins/wordbook/">Wordbook</a> plugin for WordPress which basically replicates posts from your own hosted WordPress (or WordPress MU) blog into your <a href="http://www.facebook.com/">Facebook</a> account where they appeared on your wall.

The plugin did something well but it lacked several things that I'd like it to do. So I started adding them. The sidebar widget was the easiest thing to do as that was pretty much self contained and as you can see from this blog its working quite well.

The plugin had a very annoying habit of re-posting a post if you edited after more than a few days and it seemed to publish posts to Facebook when you'd least expect it.

So I rehashed that code and got it all working.

But everything was hard coded. What if I wanted to force it to republish a post to Facebook when I edited it, what if I wanted to automatically republish if editing after 10 days, except that I <em>didn't</em> want it to do it for a specific post.

That was all the easy stuff.

But what about comments? Wouldn't it be cool if comments posted on your Facebook copy of the post could be pulled down into your blog as comments to that post. Sure it would be cool, and it wouldn't be that difficult would it.

WRONG!

The plugin used the <a href="http://wiki.developers.facebook.com/index.php/Feed.publishUserAction" target="_blank">Feed.publishUserAction</a> API call. Its a neat little function but it doesn't return the Post ID for the post you just made into facebook, and you need the Post ID to pull comments back. The obvious answer was to use the <a href="http://wiki.developers.facebook.com/index.php/Stream.publish">stream.publish</a> API call instead. That returns the Post ID and then you can simply get the comments by using <a href="http://wiki.developers.facebook.com/index.php/Stream.getComments">Stream.getComments</a> and passing it the post ID in question. To get all of that working I needed to grab the latest version of the API files and I had to recode the way the plugin posts as Stream.Publish uses a different structure for a post.

So once all that was working and I'd coded up a nice options page and put an option block on the Edit/Add Posts page so you can override some defaults (like saying you DON'T want to import comments for a post) all that was left was to code up a comment fetching job and work with WP-CRON to schedule it.

I finished all of that a couple of weeks ago, and I've been debugging it since but now I think its probably ready to escape into the wild and if anyone is mad enough to want to test it then <a href="http://blogs.canalplan.org.uk/steve/files/2009/11/wordbook1.0.zip">Here it is </a>

<span style="font-size: medium"><strong>Some quick notes on Upgrading from the existing Wordbook plugin.</strong></span>
<ul>
	<li>You need to de-activate the old plug in first.</li>
	<li>Then DELETE the wordbook folder from wp-content/plugins and then upload the new version. DONT just copy the new files up.</li>
	<li>Re-activate the plugin</li>
	<li>Go to the Options page for the plugin and you can set all the new wizzy options. If you want to pull comments from your Facebook account you'll need to grant the plugin permission to read from your stream. If you don't grant this permission then you can't pull comments, and I've no idea what my code will do if it tries to do that because I didn't test it! So <em>you have been warned! </em></li>
</ul>
<span style="font-size: medium"><strong>Debugging.</strong></span>
The only place I've put any real debugging in is in the cron job code because its very hard to actually work out if its working if there are no comments to pull. Debugging for that can be enabled by editing two lines in wordbook_cron.php:

<em>define ('DEBUG', false); </em> which you change to true
and
<em>$debug_file='/tmp/wordbook_'.$table_prefix.'debug'; </em>which you may need to change if you want to change the output directory.

<strong><span style="font-size: medium">Caveats</span></strong>

You knew there would be some didn't you!

I developed this on WordPress MU which is the MultiUser version of WordPress. I developed it  using 2.8.4a which is the same as 2.8.4 in standard WordPress. I HAVE NOT tested it on older versions so I cannot guarantee things like the draggable box on the Edit/Add Page will work if you are not on V2.8.4

As I've now sort of released this plugin I've created a page where I'll log any changes to it in future. So if you want to keep upto date then you'll need to check my <a href="http://blogs.canalplan.org.uk/steve/wordbook/">Wordbook Page</a>]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/6nCog5fKLM9fAk2lBZRLlbF-WVY/0/da"><img src="http://feedads.g.doubleclick.net/~a/6nCog5fKLM9fAk2lBZRLlbF-WVY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/6nCog5fKLM9fAk2lBZRLlbF-WVY/1/da"><img src="http://feedads.g.doubleclick.net/~a/6nCog5fKLM9fAk2lBZRLlbF-WVY/1/di" border="0" ismap="true"></img></a></p>Back in<a href="http://blogs.canalplan.org.uk/steve/2009/08/11/wordpress-and-facebook-part-3/"> August I wrote </a>about the <a href="http://wordpress.org/extend/plugins/wordbook/">Wordbook</a> plugin for WordPress which basically replicates posts from your own hosted WordPress (or WordPress MU) blog into your <a href="http://www.facebook.com/">Facebook</a> account where they appeared on your wall.

The plugin did something well but it lacked several things that I'd like it to do. So I started adding them. The sidebar widget was the easiest thing to do as that was pretty much self contained and as you can see from this blog its working quite well.

The plugin had a very annoying habit of re-posting a post if you edited after more than a few days and it seemed to publish posts to Facebook when you'd least expect it.

So I rehashed that code and got it all working.

But everything was hard coded. What if I wanted to force it to republish a post to Facebook when I edited it, what if I wanted to automatically republish if editing after 10 days, except that I <em>didn't</em> want it to do it for a specific post.

That was all the easy stuff.

But what about comments? Wouldn't it be cool if comments posted on your Facebook copy of the post could be pulled down into your blog as comments to that post. Sure it would be cool, and it wouldn't be that difficult would it.

WRONG!

The plugin used the <a href="http://wiki.developers.facebook.com/index.php/Feed.publishUserAction" target="_blank">Feed.publishUserAction</a> API call. Its a neat little function but it doesn't return the Post ID for the post you just made into facebook, and you need the Post ID to pull comments back. The obvious answer was to use the <a href="http://wiki.developers.facebook.com/index.php/Stream.publish">stream.publish</a> API call instead. That returns the Post ID and then you can simply get the comments by using <a href="http://wiki.developers.facebook.com/index.php/Stream.getComments">Stream.getComments</a> and passing it the post ID in question. To get all of that working I needed to grab the latest version of the API files and I had to recode the way the plugin posts as Stream.Publish uses a different structure for a post.

So once all that was working and I'd coded up a nice options page and put an option block on the Edit/Add Posts page so you can override some defaults (like saying you DON'T want to import comments for a post) all that was left was to code up a comment fetching job and work with WP-CRON to schedule it.

I finished all of that a couple of weeks ago, and I've been debugging it since but now I think its probably ready to escape into the wild and if anyone is mad enough to want to test it then <a href="http://blogs.canalplan.org.uk/steve/files/2009/11/wordbook1.0.zip">Here it is </a>

<span style="font-size: medium"><strong>Some quick notes on Upgrading from the existing Wordbook plugin.</strong></span>
<ul>
	<li>You need to de-activate the old plug in first.</li>
	<li>Then DELETE the wordbook folder from wp-content/plugins and then upload the new version. DONT just copy the new files up.</li>
	<li>Re-activate the plugin</li>
	<li>Go to the Options page for the plugin and you can set all the new wizzy options. If you want to pull comments from your Facebook account you'll need to grant the plugin permission to read from your stream. If you don't grant this permission then you can't pull comments, and I've no idea what my code will do if it tries to do that because I didn't test it! So <em>you have been warned! </em></li>
</ul>
<span style="font-size: medium"><strong>Debugging.</strong></span>
The only place I've put any real debugging in is in the cron job code because its very hard to actually work out if its working if there are no comments to pull. Debugging for that can be enabled by editing two lines in wordbook_cron.php:

<em>define ('DEBUG', false); </em> which you change to true
and
<em>$debug_file='/tmp/wordbook_'.$table_prefix.'debug'; </em>which you may need to change if you want to change the output directory.

<strong><span style="font-size: medium">Caveats</span></strong>

You knew there would be some didn't you!

I developed this on WordPress MU which is the MultiUser version of WordPress. I developed it  using 2.8.4a which is the same as 2.8.4 in standard WordPress. I HAVE NOT tested it on older versions so I cannot guarantee things like the draggable box on the Edit/Add Page will work if you are not on V2.8.4

As I've now sort of released this plugin I've created a page where I'll log any changes to it in future. So if you want to keep upto date then you'll need to check my <a href="http://blogs.canalplan.org.uk/steve/wordbook/">Wordbook Page</a><img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/bm2DBqd1qWs" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/10/28/wordpress-and-facebook-part-4/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/10/28/wordpress-and-facebook-part-4/</feedburner:origLink></item>
						<item>
				<title>Posting to Wordpress MU by Email Part 2</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/t6EHYIDStlc/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/10/20/posting-to-wordpress-mu-by-email-part-2/#comments</comments>
				<pubDate>Tue, 20 Oct 2009 09:58:58 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/10/20/posting-to-wordpress-mu-by-email-part-2/</guid>
                <description><![CDATA[<strong>Warning: </strong>This post contains material of a technical nature, if you start reading and feel dizzy or nauseous then stop reading immediately and go and lie down.

This is a follow up to my <a href="//blogs.canalplan.org.uk/steve/2009/10/07/posting-to-wordpress-mu-by-email/">previous post</a> where I outlined a prototype of an extension for WPMU which allowed posting to multiple blogs from one centralised POP3 account which collected<em> all</em> posts from <em>all</em> users of <em>all</em> blogs. This is very different from the usual way of doing it where you either go out to get the emails from external email addresses or you have multiple local accounts.

Well the prototype has, like Frankenstein's Monster, come alive and it's now got configuration screens and lots of rich techy goodness to it.

I'm not going to go over the instructions on how to configure the MTA again, those are documented on my last post, and in the notes in the downloadable archive :

<a href='http://blogs.canalplan.org.uk/steve/files/2009/10/Post-by-Email.zip'> Post by Email</a> Post by Email-v1.zip

The Archive also contains instructions on where the TWO files need to be placed for the system to work.

What I'm going to cover here is the new features that I've added since the last post. Yes I have way too much time on my hands, but this is keeping my brain sharp so its all good at the end of the day.

These can be broken down into to distinct groups which are reflected in the two new options that will appear on the Settings menu:

<span style="font-size: medium"><strong>Blog Level Options</strong></span>

These are options which are set by the blog administrator or blog owner:

<strong>Default Category for posts</strong> : This is a drop down of all categories and you select one to be the default category for posts without a <em>category override</em>

<strong>Optional Categories</strong>: This is a tick box list of all other categories in your blog, Toggle the ones you want users to be able to use in their category override.

<strong>Allow Posting By</strong>:  This is a tick box list of all the user who are members of your blog. Toggle the ones you want to be able to use the post by email. This will include YOUR address and by default no-one of them are checked (which basically deactivates the system for your specific blog).

<span style="font-size: medium"><strong>User Level Options</strong></span>

These are options which are set on a user by user basis.

<strong>Personal Identifier </strong>: This is a optional text string which allows users to "secure" their posts. If this has been set then posts from them will be rejected outright. So set this to something good but memorable as you'll have to provide it for each post.

Alternative Email: This allows you to nominate a secondary email address which the system will accept emails from. If you do not set this then posts will only be accepted<em> from the email address registered to your account.</em>

<span style="font-size: medium"><strong>Additional Posting options</strong></span>

To support the "new" features there are now some additional posting options which you set at the top of your email.

<strong>wppbm-categories</strong>: A comma separated list of category names for this post. NOTE: This is names not numbers which makes it easier to remember (or are you so sad that you know the underlying IDs of your categories). You'll find a list of the available categories on your user settings page. So assuming that the Administrator has enabled them you could do something like: <em>wppbm-categories : computing,witterings</em> which would post your post with those categories. If you do not specify this line then the default category set by the Administrator will be applied.

<strong>wppbm-pid</strong>: Your PID. If you've set your PID then you <em>have </em>to provide it here. If you've set it and don't include it (or get it wrong) then your post is toast!


So that's basically it. I've created a dedicated <a title="Link to my Post by Email Page" href="http://blogs.canalplan.org.uk/steve/post-by-mail/" target="_blank">Post by Email Page </a>where I'll always list the current version and the bug fixes/enhancements.


So download it, configure it and play with it and bounce bugs back to me as comments!]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/U2UpCSPooEHZdA2Jm4rlRqDYAy0/0/da"><img src="http://feedads.g.doubleclick.net/~a/U2UpCSPooEHZdA2Jm4rlRqDYAy0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/U2UpCSPooEHZdA2Jm4rlRqDYAy0/1/da"><img src="http://feedads.g.doubleclick.net/~a/U2UpCSPooEHZdA2Jm4rlRqDYAy0/1/di" border="0" ismap="true"></img></a></p><strong>Warning: </strong>This post contains material of a technical nature, if you start reading and feel dizzy or nauseous then stop reading immediately and go and lie down.

This is a follow up to my <a href="//blogs.canalplan.org.uk/steve/2009/10/07/posting-to-wordpress-mu-by-email/">previous post</a> where I outlined a prototype of an extension for WPMU which allowed posting to multiple blogs from one centralised POP3 account which collected<em> all</em> posts from <em>all</em> users of <em>all</em> blogs. This is very different from the usual way of doing it where you either go out to get the emails from external email addresses or you have multiple local accounts.

Well the prototype has, like Frankenstein's Monster, come alive and it's now got configuration screens and lots of rich techy goodness to it.

I'm not going to go over the instructions on how to configure the MTA again, those are documented on my last post, and in the notes in the downloadable archive :

<a href='http://blogs.canalplan.org.uk/steve/files/2009/10/Post-by-Email.zip'> Post by Email</a> Post by Email-v1.zip

The Archive also contains instructions on where the TWO files need to be placed for the system to work.

What I'm going to cover here is the new features that I've added since the last post. Yes I have way too much time on my hands, but this is keeping my brain sharp so its all good at the end of the day.

These can be broken down into to distinct groups which are reflected in the two new options that will appear on the Settings menu:

<span style="font-size: medium"><strong>Blog Level Options</strong></span>

These are options which are set by the blog administrator or blog owner:

<strong>Default Category for posts</strong> : This is a drop down of all categories and you select one to be the default category for posts without a <em>category override</em>

<strong>Optional Categories</strong>: This is a tick box list of all other categories in your blog, Toggle the ones you want users to be able to use in their category override.

<strong>Allow Posting By</strong>:  This is a tick box list of all the user who are members of your blog. Toggle the ones you want to be able to use the post by email. This will include YOUR address and by default no-one of them are checked (which basically deactivates the system for your specific blog).

<span style="font-size: medium"><strong>User Level Options</strong></span>

These are options which are set on a user by user basis.

<strong>Personal Identifier </strong>: This is a optional text string which allows users to "secure" their posts. If this has been set then posts from them will be rejected outright. So set this to something good but memorable as you'll have to provide it for each post.

Alternative Email: This allows you to nominate a secondary email address which the system will accept emails from. If you do not set this then posts will only be accepted<em> from the email address registered to your account.</em>

<span style="font-size: medium"><strong>Additional Posting options</strong></span>

To support the "new" features there are now some additional posting options which you set at the top of your email.

<strong>wppbm-categories</strong>: A comma separated list of category names for this post. NOTE: This is names not numbers which makes it easier to remember (or are you so sad that you know the underlying IDs of your categories). You'll find a list of the available categories on your user settings page. So assuming that the Administrator has enabled them you could do something like: <em>wppbm-categories : computing,witterings</em> which would post your post with those categories. If you do not specify this line then the default category set by the Administrator will be applied.

<strong>wppbm-pid</strong>: Your PID. If you've set your PID then you <em>have </em>to provide it here. If you've set it and don't include it (or get it wrong) then your post is toast!


So that's basically it. I've created a dedicated <a title="Link to my Post by Email Page" href="http://blogs.canalplan.org.uk/steve/post-by-mail/" target="_blank">Post by Email Page </a>where I'll always list the current version and the bug fixes/enhancements.


So download it, configure it and play with it and bounce bugs back to me as comments!<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/t6EHYIDStlc" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/10/20/posting-to-wordpress-mu-by-email-part-2/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/10/20/posting-to-wordpress-mu-by-email-part-2/</feedburner:origLink></item>
						<item>
				<title>Posting to Wordpress MU by email</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/1bNU3LXsp7E/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/10/07/posting-to-wordpress-mu-by-email/#comments</comments>
				<pubDate>Wed, 07 Oct 2009 10:57:37 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/10/07/posting-to-wordpress-mu-by-email/</guid>
                <description><![CDATA[<strong>Warning: </strong>This post contains material of a technical nature, if you start reading and feel dizzy or nauseous then stop reading immediately and go and lie down.

<strong>NOTE: </strong> The code and some of the details in this article have been superseded by a <a href="http://blogs.canalplan.org.uk/steve/2009/10/20/posting-to-wordpress-mu-by-email-part-2/">later post</a> 

There are a lot of clients for the PC/Mac/Linux which allow you to post to your WordPress blog without having to log into the back end, and some might question the need to be able to send posts into your blog via email but there are several situations where you can't use a fat client or you don't want to use the web back end for various reasons

Wordpress MU (the multi-user/multi-blog version of WordPress) supports a basic post by email feature but it involves each user setting up their account to go out to an <em>external</em> email address and picking up the email. This seems rather "backwards" as it means your WPMU server is having to go out to find your new posts, and if you've got a lot of blogs then that's potentially a lot of outgoing POP3 requests and it means that your have got the email account and passwords for your users, which some might see as not being a <em>very good idea</em>. WPMU suggest using a specific account to support posting by email and keeping the account "secret".

Surely it makes sense for the posts to be delivered to the WPMU server and processed there. This has several advantages when you think about it.

So I've written a new version which uses a local virtual domain and a single pop3 box.

So the user emails theirwpmuloginid@some.domain.here which ends up in a pop3 mail box on a server somewhere (preferably the same server as WPMU). Every email sent to some.domain.here arrives into one single pop3 mail box rather than being in different ones. This "catch all" account means that you don't have to do anything clever like creating email accounts for each user as they sign up.

My process then opens that pop3 account and reads each email in turn.

It will only post if the sender email ID matches the username it is associated with (from the user table). So you have to send email from <em>the email address you signed up with, or the email address you've set it to in your account settings</em> and you have to send it to the username you use to login to the site as. This is only very basic security and I will be adding more but for the first pass of the code I felt that this was good enough to prove the principle.

So apart from allowing me to post to my blog via email what else does this "extension" provide? Well users  can specify some "options" in the email which affect how their post is handled:

There are currently 4 options that they can provide:

<em>wppbm-tags</em>: comma separated list of tags for this post
<em>wppbm-status</em>: publish [default] | draft | pending
<em>wppbm-type</em>: post [default] | page
<em>wppbm-comments</em>: open [default] | closed

All of these options are optional, you do not have to provide them and if you don't provide them then the defaults indicated will apply. WPMU developers who have played with the wp_insert_post function will probably recognise them.

Posts accepted by email will be assigned to the default category for new posts.

It currently accepts basic html marked up (bold, italic, underline) messages (either manually coded or from the rich text editor in Google mail). Yahoo marks its html messages up differently so its not working if you try to use their Rich Text Editor, and "advanced" html mark up (like font sizes etc.) don't work from Googlemail either.  Again this will be addressed in a future release.

Things that need adding are:
<ul>
	<li>A PID field (so that people can't just "fake" the sender email address).</li>
	<li>Ability to support posting to different blogs (rather than just primary).</li>
	<li>Ability to support posting from more than one email account.</li></ul>



So if people want to try it, and leave feedback then this is how you implement it. If you can't edit your Postfix configuration (or don't know how to) then I'm sorry but I can't help you. I don't know if other MTAs support virtual domains but if they do and you get it working then we can add those instructions. 

I've only tested this on Linux so you've been warned!!!

In these instructions I'm using posts.my-dummy.domain to represent the domain we'll be using to send emails to.

<strong>Step 1 : DNS Records</strong>
Configure your DNS records to support posts.my-dummy.domain. You need to be able to send email to this domain.

<strong>Step 2 : Create a REAL email account on your server.</strong>
However you do it you need a local email account on the server that you'll be directing email to. In this example I'm going to call this user<em> wpmuposts </em>

<strong>Step 3 : Postfix Configuration</strong>
Edit your postfix main.cf file and add the following two lines:

<code>virtual_alias_domains = posts.my-dummy.domain
virtual_alias_maps=hash:/etc/postfix/virtual</code>


<strong>NOTE:</strong> The virtual_alias_domain <strong>MUST NOT</strong> be listed in the <em>mydestinations</em> configuration parameter.

Create/edit the /etc/postfix/virtual file and add the following line :

<code>@posts.my-dummy.domain wpmuposts</code>

Save the file, and then you need to create a hash for it using the postmap command. I do this by going to the postfix directory (/etc/postfix on my server) and typing:

<code>postmap virtual</code>

You may then wish to check that everything works by waiting for your DNS to propogate and then going to an external email client and sending an email to anything-here@my-dummy.domain.

You <em>should</em> end up with an email sitting in the POP3 email box wpmuposts. If not then you need to review your settings. There is no point in going beyond this point unless you've got the "catch all" email working.

OK so email is now working. That really was the <em>hard </em>part. The rest is pretty easy, and if you're doing this then going in and editing a php file isn't the sort of thing that scares you right?
<strong>
Step 4 : Getting and configuring the extension</strong>

Grab a copy of <a href='http://blogs.canalplan.org.uk/steve/files/2009/10/post_by_mail.php.txt'>post_by_mail.php</a> and save it to your computer.

Open the file in your favourite text editor and look for the following :

<code>// USER NEEDS TO SET THESE.
// Postfix will need configuring to support virtual domains with a wildcard to deliver to the account given below.
define ("POP3HOST","your host here");
define ("POP3PORT","110");
define ("POP3USER","special pop3 user account here");
define ("POP3PASS","special pop3 user password here");
///</code>

and edit them to match the POP3 settings you need to access your special POP3 email account: So for example:

<code>// USER NEEDS TO SET THESE.
// Postfix will need configuring to support virtual domains with a wildcard to deliver to the account given below.
define ("POP3HOST","localhost");
define ("POP3PORT","110");
define ("POP3USER","wpmuposts");
define ("POP3PASS","notarealpassword");
///</code>

Save the file and then upload it to the ROOT of your WPMU installation.  <strong>DON'T FORGET TO REMOVE the .TXT extension!</strong>


That's basically it, the extension is there. If you want to give it a different name, for security reasons, then feel free to.

To test it, send an email (and I'd suggest setting the wppbm-status to draft) to yourwpmulogon@posts.my-dummy.domain. Then once its arrived call:

http://my-wp.domain.here/posts_by_mail.php

You should see some diagnostic message on the screen and hopefully, fingers crossed, you'll end up with a new post in your blog.

So all you then need to do is set up a cron job. At the moment you can't use the PHP CLI to run this code but you can set up a cron job to to a wget on the URL. As this isn't a silent process I don't recommend putting a call to it into your themes, its much better to keep it controlled by cron (and that way you can route the output to a log file to keep an eye on it).

<strong>Debugging</strong>
If you think that there are problems and you want to keep checking the same email as you add debug code to the extension then you'll want to stop it deleting emails / posting messages.

To stop it posting into your blog look for the following line (line 241):

	<code>$post_ID = wp_insert_post($post_data);</code>

and put a # in front of it.

To stop it deleting messages on completion look for the following code (line 256 - 262):

<code>	if(!$pop3-&gt;delete($i)) {
		echo '	&lt;p&gt;' . sprintf(__('Oops: %s'), esc_html($pop3-&gt;ERROR)) . '	&lt;/p&gt;';
		$pop3-&gt;reset();
		exit;
	} else {
		echo '	&lt;p&gt;' . sprintf(__('Mission complete.  Message &lt;strong&gt;%s&lt;/strong&gt; deleted.'), $i) . '	&lt;/p	&gt;';
	}</code>

and comment it out.

So there you go. Please remember that is a work in progress and support for complex HTML isn't there and you install it at your own risk. If you've got any suggestions on improvements, or you've found a bug then please let me know.

]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/Vype0cIDAa9a2NUcy9VaAwq-Xms/0/da"><img src="http://feedads.g.doubleclick.net/~a/Vype0cIDAa9a2NUcy9VaAwq-Xms/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Vype0cIDAa9a2NUcy9VaAwq-Xms/1/da"><img src="http://feedads.g.doubleclick.net/~a/Vype0cIDAa9a2NUcy9VaAwq-Xms/1/di" border="0" ismap="true"></img></a></p><strong>Warning: </strong>This post contains material of a technical nature, if you start reading and feel dizzy or nauseous then stop reading immediately and go and lie down.

<strong>NOTE: </strong> The code and some of the details in this article have been superseded by a <a href="http://blogs.canalplan.org.uk/steve/2009/10/20/posting-to-wordpress-mu-by-email-part-2/">later post</a> 

There are a lot of clients for the PC/Mac/Linux which allow you to post to your WordPress blog without having to log into the back end, and some might question the need to be able to send posts into your blog via email but there are several situations where you can't use a fat client or you don't want to use the web back end for various reasons

Wordpress MU (the multi-user/multi-blog version of WordPress) supports a basic post by email feature but it involves each user setting up their account to go out to an <em>external</em> email address and picking up the email. This seems rather "backwards" as it means your WPMU server is having to go out to find your new posts, and if you've got a lot of blogs then that's potentially a lot of outgoing POP3 requests and it means that your have got the email account and passwords for your users, which some might see as not being a <em>very good idea</em>. WPMU suggest using a specific account to support posting by email and keeping the account "secret".

Surely it makes sense for the posts to be delivered to the WPMU server and processed there. This has several advantages when you think about it.

So I've written a new version which uses a local virtual domain and a single pop3 box.

So the user emails theirwpmuloginid@some.domain.here which ends up in a pop3 mail box on a server somewhere (preferably the same server as WPMU). Every email sent to some.domain.here arrives into one single pop3 mail box rather than being in different ones. This "catch all" account means that you don't have to do anything clever like creating email accounts for each user as they sign up.

My process then opens that pop3 account and reads each email in turn.

It will only post if the sender email ID matches the username it is associated with (from the user table). So you have to send email from <em>the email address you signed up with, or the email address you've set it to in your account settings</em> and you have to send it to the username you use to login to the site as. This is only very basic security and I will be adding more but for the first pass of the code I felt that this was good enough to prove the principle.

So apart from allowing me to post to my blog via email what else does this "extension" provide? Well users  can specify some "options" in the email which affect how their post is handled:

There are currently 4 options that they can provide:

<em>wppbm-tags</em>: comma separated list of tags for this post
<em>wppbm-status</em>: publish [default] | draft | pending
<em>wppbm-type</em>: post [default] | page
<em>wppbm-comments</em>: open [default] | closed

All of these options are optional, you do not have to provide them and if you don't provide them then the defaults indicated will apply. WPMU developers who have played with the wp_insert_post function will probably recognise them.

Posts accepted by email will be assigned to the default category for new posts.

It currently accepts basic html marked up (bold, italic, underline) messages (either manually coded or from the rich text editor in Google mail). Yahoo marks its html messages up differently so its not working if you try to use their Rich Text Editor, and "advanced" html mark up (like font sizes etc.) don't work from Googlemail either.  Again this will be addressed in a future release.

Things that need adding are:
<ul>
	<li>A PID field (so that people can't just "fake" the sender email address).</li>
	<li>Ability to support posting to different blogs (rather than just primary).</li>
	<li>Ability to support posting from more than one email account.</li></ul>



So if people want to try it, and leave feedback then this is how you implement it. If you can't edit your Postfix configuration (or don't know how to) then I'm sorry but I can't help you. I don't know if other MTAs support virtual domains but if they do and you get it working then we can add those instructions. 

I've only tested this on Linux so you've been warned!!!

In these instructions I'm using posts.my-dummy.domain to represent the domain we'll be using to send emails to.

<strong>Step 1 : DNS Records</strong>
Configure your DNS records to support posts.my-dummy.domain. You need to be able to send email to this domain.

<strong>Step 2 : Create a REAL email account on your server.</strong>
However you do it you need a local email account on the server that you'll be directing email to. In this example I'm going to call this user<em> wpmuposts </em>

<strong>Step 3 : Postfix Configuration</strong>
Edit your postfix main.cf file and add the following two lines:

<code>virtual_alias_domains = posts.my-dummy.domain
virtual_alias_maps=hash:/etc/postfix/virtual</code>


<strong>NOTE:</strong> The virtual_alias_domain <strong>MUST NOT</strong> be listed in the <em>mydestinations</em> configuration parameter.

Create/edit the /etc/postfix/virtual file and add the following line :

<code>@posts.my-dummy.domain wpmuposts</code>

Save the file, and then you need to create a hash for it using the postmap command. I do this by going to the postfix directory (/etc/postfix on my server) and typing:

<code>postmap virtual</code>

You may then wish to check that everything works by waiting for your DNS to propogate and then going to an external email client and sending an email to anything-here@my-dummy.domain.

You <em>should</em> end up with an email sitting in the POP3 email box wpmuposts. If not then you need to review your settings. There is no point in going beyond this point unless you've got the "catch all" email working.

OK so email is now working. That really was the <em>hard </em>part. The rest is pretty easy, and if you're doing this then going in and editing a php file isn't the sort of thing that scares you right?
<strong>
Step 4 : Getting and configuring the extension</strong>

Grab a copy of <a href='http://blogs.canalplan.org.uk/steve/files/2009/10/post_by_mail.php.txt'>post_by_mail.php</a> and save it to your computer.

Open the file in your favourite text editor and look for the following :

<code>// USER NEEDS TO SET THESE.
// Postfix will need configuring to support virtual domains with a wildcard to deliver to the account given below.
define ("POP3HOST","your host here");
define ("POP3PORT","110");
define ("POP3USER","special pop3 user account here");
define ("POP3PASS","special pop3 user password here");
///</code>

and edit them to match the POP3 settings you need to access your special POP3 email account: So for example:

<code>// USER NEEDS TO SET THESE.
// Postfix will need configuring to support virtual domains with a wildcard to deliver to the account given below.
define ("POP3HOST","localhost");
define ("POP3PORT","110");
define ("POP3USER","wpmuposts");
define ("POP3PASS","notarealpassword");
///</code>

Save the file and then upload it to the ROOT of your WPMU installation.  <strong>DON'T FORGET TO REMOVE the .TXT extension!</strong>


That's basically it, the extension is there. If you want to give it a different name, for security reasons, then feel free to.

To test it, send an email (and I'd suggest setting the wppbm-status to draft) to yourwpmulogon@posts.my-dummy.domain. Then once its arrived call:

http://my-wp.domain.here/posts_by_mail.php

You should see some diagnostic message on the screen and hopefully, fingers crossed, you'll end up with a new post in your blog.

So all you then need to do is set up a cron job. At the moment you can't use the PHP CLI to run this code but you can set up a cron job to to a wget on the URL. As this isn't a silent process I don't recommend putting a call to it into your themes, its much better to keep it controlled by cron (and that way you can route the output to a log file to keep an eye on it).

<strong>Debugging</strong>
If you think that there are problems and you want to keep checking the same email as you add debug code to the extension then you'll want to stop it deleting emails / posting messages.

To stop it posting into your blog look for the following line (line 241):

	<code>$post_ID = wp_insert_post($post_data);</code>

and put a # in front of it.

To stop it deleting messages on completion look for the following code (line 256 - 262):

<code>	if(!$pop3-&gt;delete($i)) {
		echo '	&lt;p&gt;' . sprintf(__('Oops: %s'), esc_html($pop3-&gt;ERROR)) . '	&lt;/p&gt;';
		$pop3-&gt;reset();
		exit;
	} else {
		echo '	&lt;p&gt;' . sprintf(__('Mission complete.  Message &lt;strong&gt;%s&lt;/strong&gt; deleted.'), $i) . '	&lt;/p	&gt;';
	}</code>

and comment it out.

So there you go. Please remember that is a work in progress and support for complex HTML isn't there and you install it at your own risk. If you've got any suggestions on improvements, or you've found a bug then please let me know.

<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/1bNU3LXsp7E" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/10/07/posting-to-wordpress-mu-by-email/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/10/07/posting-to-wordpress-mu-by-email/</feedburner:origLink></item>
						<item>
				<title>What's under the bonnet in CanalPlanAC: Part 2 - data formats</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/8kL9xrQ-HGc/</link>
				<comments>http://blogs.canalplan.org.uk/canalplanac/2009/10/03/whats-under-the-bonnet-in-canalplanac-part-2-data-formats/#comments</comments>
				<pubDate>Sat, 03 Oct 2009 08:14:41 +0000</pubDate>
				<dc:creator>Nick</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/canalplanac/2009/10/03/whats-under-the-bonnet-in-canalplanac-part-2-data-formats/</guid>
                <description><![CDATA[Over the years CanalPlanAC has accumulated a host of data formats for various purposes.  At least two - a custom C-like syntax (surprisingly similar to another I've adopted!) and "quick load" place and link files - are entirely obsolete but support for them still lurks in the interpreter.

Here are the main ones that anyone playing with the system might come across:
<ul>
	<li>SQL - since summer 2008 the main database for CanalPlanAC, the users, the information about photographs, some of the program flow control and state information during a session have been stored in SQL databases.  I'm using SQLite - this is small and can be directly integrated into the interpreter making setup very easy.</li>
	<li>XML - until then XML was used for the master data file, and quick-read varieties in a sort of unstructured text file were generated.  The unstructured files are also obsolete (although some support may still exist in route.c until I rip it out) but XML is still used although much more round the edges these days.  In particular, it's used for:
<ul>
	<li>Sending data to some Javascript utilities.</li>
	<li>Storing the configuration file /cgi-bin/config.xml which tells the program where all the data should be stored and similar things</li>
	<li>To store the default user options in a file, and the user options (in a blob) in the user SQL database</li>
	<li>To define options for gazetteer plugins (to be described some other time!)</li>
</ul>
</li>
	<li>JSON - not used statically, but used for a number of inter process and code communications (particularly those involving Javascript)</li>
	<li>HTML - static pages are written in HTML</li>
	<li>CST -<a href="http://www.clearsilver.net/" target="_blank"> ClearSilver</a> Templates.  Since summer 2007 pages are generated from template files.  This is an extended form of HTML with ClearSilver directives built into it - see the website for more.</li>
	<li>HDF - this is the configuration file language for ClearSilver.  I didn't have to use this, I've integrated ClearSilver so tightly I can easily pass it any format I like, but it seemed sensible.  The most important HDF file is /templates/default/config.hdf which controls all the menus and buttons on all the pages.</li>
</ul>
So there you are.  A pile of formats, but many of them widely known, and many of them only used in a few places.  In the next few articles I'll show how to add a sophisticated new feature (the Virtual Cruise) to CanalPlanAC and you'll see how these various languages and formats are used.]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/G7--a-R8sP9ZaWDDog85HQ6EbDU/0/da"><img src="http://feedads.g.doubleclick.net/~a/G7--a-R8sP9ZaWDDog85HQ6EbDU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/G7--a-R8sP9ZaWDDog85HQ6EbDU/1/da"><img src="http://feedads.g.doubleclick.net/~a/G7--a-R8sP9ZaWDDog85HQ6EbDU/1/di" border="0" ismap="true"></img></a></p>Over the years CanalPlanAC has accumulated a host of data formats for various purposes.  At least two - a custom C-like syntax (surprisingly similar to another I've adopted!) and "quick load" place and link files - are entirely obsolete but support for them still lurks in the interpreter.

Here are the main ones that anyone playing with the system might come across:
<ul>
	<li>SQL - since summer 2008 the main database for CanalPlanAC, the users, the information about photographs, some of the program flow control and state information during a session have been stored in SQL databases.  I'm using SQLite - this is small and can be directly integrated into the interpreter making setup very easy.</li>
	<li>XML - until then XML was used for the master data file, and quick-read varieties in a sort of unstructured text file were generated.  The unstructured files are also obsolete (although some support may still exist in route.c until I rip it out) but XML is still used although much more round the edges these days.  In particular, it's used for:
<ul>
	<li>Sending data to some Javascript utilities.</li>
	<li>Storing the configuration file /cgi-bin/config.xml which tells the program where all the data should be stored and similar things</li>
	<li>To store the default user options in a file, and the user options (in a blob) in the user SQL database</li>
	<li>To define options for gazetteer plugins (to be described some other time!)</li>
</ul>
</li>
	<li>JSON - not used statically, but used for a number of inter process and code communications (particularly those involving Javascript)</li>
	<li>HTML - static pages are written in HTML</li>
	<li>CST -<a href="http://www.clearsilver.net/" target="_blank"> ClearSilver</a> Templates.  Since summer 2007 pages are generated from template files.  This is an extended form of HTML with ClearSilver directives built into it - see the website for more.</li>
	<li>HDF - this is the configuration file language for ClearSilver.  I didn't have to use this, I've integrated ClearSilver so tightly I can easily pass it any format I like, but it seemed sensible.  The most important HDF file is /templates/default/config.hdf which controls all the menus and buttons on all the pages.</li>
</ul>
So there you are.  A pile of formats, but many of them widely known, and many of them only used in a few places.  In the next few articles I'll show how to add a sophisticated new feature (the Virtual Cruise) to CanalPlanAC and you'll see how these various languages and formats are used.<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/8kL9xrQ-HGc" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/canalplanac/2009/10/03/whats-under-the-bonnet-in-canalplanac-part-2-data-formats/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/canalplanac/2009/10/03/whats-under-the-bonnet-in-canalplanac-part-2-data-formats/</feedburner:origLink></item>
						<item>
				<title>What's under the bonnet in CanalPlanAC: Part 1 - programming languages</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/Rf5fyLfTBAI/</link>
				<comments>http://blogs.canalplan.org.uk/canalplanac/2009/10/01/whats-under-the-bonnet-in-canalplanac-part-1-programming-languages/#comments</comments>
				<pubDate>Thu, 01 Oct 2009 07:08:19 +0000</pubDate>
				<dc:creator>Nick</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/canalplanac/2009/10/01/whats-under-the-bonnet-in-canalplanac-part-1-programming-languages/</guid>
                <description><![CDATA[OK, at the moment no-one is developing the program apart from myself. But it struck me that if I documented a few things as if people were, then I'd have a lot of stuff ready if ever I get a co-developer or even hand on the project.

The Canal Planner situation has, I think, shown us the danger of a project like this being all in the mind of one individual.

So what I'll be doing from time to time is documenting how I did particular things, in a sort of "tutorial" way.  But before I do that, I thought I'd start with a sort of apology for the number of languages (big and small) used in CanalPlanAC.  I thought it might be fun to document them all - but don't let this put anyone off: you don't need all of them at any one time.
<ul>
	<li>C - the Interpreter that underlies CanalPlanAC is written in C.  This can remain unchanged for months, until I discover a bug or find the need to add a feature right into the language.  What tends to happen is that I write something in the scripting langauge but find it too slow or too cumbersome, so add it as a language feature instead.    There is - as yet - no modular extensibility to the C: there are about 35 thousand lines of C in 87 source files that I've written,and a chunk more in various pieces of "foreign" code that are linked in.</li>
	<li>CanalPlanAC scripting language.  I have no name for this language, which can be invoked interactively by /cgi-bin/canal/ or to execute a file as /cgi-bin/canal file.can.  This is a basic like language that deserves another dozen items on the syntax.  It was vaguely inspired by Superbasic which could give you a few pointers to some of the syntax.  Key things about it are:
<ul>
	<li>An intermediate typing system where all values are one of a number of types, and get coerced from one to the other when assigned.</li>
	<li>Support for associative arrays (called "lookup" tables) and lists</li>
	<li>Inline operators: this is a mixed blessing - a line like «if a contains "hello" then ...» is easy to read, but precedence sometimes goes wrong.  (So «print 'this is me and you' after 'me' contains 'you'» produces the whole string (because it parses as evalutate «'me' contains 'you'» which is 0, then returns the original string after character 0.</li>
	<li>Built-in comprehension of a waterways network with the ability to plan routes aroung it and travel along them.</li>
	<li>Built-in read/write of SQL, JSON and XML</li>
</ul>
</li>
	<li>There are a few small bash scripts, mainly to kick off CanalPlan programs.</li>
	<li>There is the whole automake/autoconf nest of snakes in /source/ but that shouldn't need touching.</li>
	<li>Many web pages use Javascript (both home written and some appropriately licensed utilities) to do place name lookup, display maps etc.</li>
</ul>
Next - the data formats that these programs use to store data, communicate with them selves and talk to the user
<div id="_mcePaste" style="overflow: hidden;width: 1px;height: 1px">OK, at the moment no-one is developing the program apart from myself.

But it struck me that if I documented a few things as if people were,

then I'd have a lot of stuff ready if ever I get a co-developer or

even hand on the project.

The Canal Planner situation has, I think, shown us the danger of a

project like this being all in the mind of one individual.

So what I'll be doing from time to time is documenting how I did

particular things, in a sort of "tutorial" way.  The first thing to do

is to start with an apology for the number of languages (big and

small) used in CanalPlanAC.  I thought it might be fun to document

them all - but don't let this put anyone off: you don't need all of

them at any one time.

*C - the Interpreter that underlies CanalPlanAC is written in C.  This

can remain unchanged for months, until I discover a bug or find the

need to add a feature right into the language.  What tends to happen

is that I write something in the scripting langauge but find it too

slow or too cumbersome, so add it as a language feature instead.

There is - as yet - no modular extensibility to the C: there are

about 35 thousand lines of C in 87 source files that I've written,

and a chunk more in various pieces of "foreign" code that are linked

in.

*CanalPlanAC scripting language.  I have no name for this language,

which can be invoked interactively by /cgi-bin/canal/ or to execute a

file as /cgi-bin/canal file.can.  This is a basic like language that deserves another dozen items on the syntax.  It was vaguely inspired by Superbasic which could give you a few pointers to some of the syntax.  Key things about it are:

**An intermediate typing system where all values are one of a number of types, and get coerced from one to the other when assigned.

**Support for associative arrays (called "lookup" tables) and lists

**Inline operators: this is a mixed blessing - a line like «if a contains "hello" then ...» is easy to read, but precedence sometimes goes wrong.  (So «print 'this is me and you' after 'me' contains 'you'» produces the whole string (because it parses as evalutate «'me' contains 'you'» which is 0, then returns the original string after character 0.

**Built-in comprehension of a waterways network with the ability to plan routes aroung it and travel along them.

**Built-in read/write of SQL, JSON and XML

*There are a few small bash scripts, mainly to kick off CanalPlan programs.

*There is the whole automake/autoconf nest of snakes in /source/ but that shouldn't need touching.

*Many web pages use Javascript (both home written and some appropriately licensed utilities) to do place name lookup, display maps etc.</div>]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/L-Q0_V9JONX9vXlgMn6EI7JgPT8/0/da"><img src="http://feedads.g.doubleclick.net/~a/L-Q0_V9JONX9vXlgMn6EI7JgPT8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/L-Q0_V9JONX9vXlgMn6EI7JgPT8/1/da"><img src="http://feedads.g.doubleclick.net/~a/L-Q0_V9JONX9vXlgMn6EI7JgPT8/1/di" border="0" ismap="true"></img></a></p>OK, at the moment no-one is developing the program apart from myself. But it struck me that if I documented a few things as if people were, then I'd have a lot of stuff ready if ever I get a co-developer or even hand on the project.

The Canal Planner situation has, I think, shown us the danger of a project like this being all in the mind of one individual.

So what I'll be doing from time to time is documenting how I did particular things, in a sort of "tutorial" way.  But before I do that, I thought I'd start with a sort of apology for the number of languages (big and small) used in CanalPlanAC.  I thought it might be fun to document them all - but don't let this put anyone off: you don't need all of them at any one time.
<ul>
	<li>C - the Interpreter that underlies CanalPlanAC is written in C.  This can remain unchanged for months, until I discover a bug or find the need to add a feature right into the language.  What tends to happen is that I write something in the scripting langauge but find it too slow or too cumbersome, so add it as a language feature instead.    There is - as yet - no modular extensibility to the C: there are about 35 thousand lines of C in 87 source files that I've written,and a chunk more in various pieces of "foreign" code that are linked in.</li>
	<li>CanalPlanAC scripting language.  I have no name for this language, which can be invoked interactively by /cgi-bin/canal/ or to execute a file as /cgi-bin/canal file.can.  This is a basic like language that deserves another dozen items on the syntax.  It was vaguely inspired by Superbasic which could give you a few pointers to some of the syntax.  Key things about it are:
<ul>
	<li>An intermediate typing system where all values are one of a number of types, and get coerced from one to the other when assigned.</li>
	<li>Support for associative arrays (called "lookup" tables) and lists</li>
	<li>Inline operators: this is a mixed blessing - a line like «if a contains "hello" then ...» is easy to read, but precedence sometimes goes wrong.  (So «print 'this is me and you' after 'me' contains 'you'» produces the whole string (because it parses as evalutate «'me' contains 'you'» which is 0, then returns the original string after character 0.</li>
	<li>Built-in comprehension of a waterways network with the ability to plan routes aroung it and travel along them.</li>
	<li>Built-in read/write of SQL, JSON and XML</li>
</ul>
</li>
	<li>There are a few small bash scripts, mainly to kick off CanalPlan programs.</li>
	<li>There is the whole automake/autoconf nest of snakes in /source/ but that shouldn't need touching.</li>
	<li>Many web pages use Javascript (both home written and some appropriately licensed utilities) to do place name lookup, display maps etc.</li>
</ul>
Next - the data formats that these programs use to store data, communicate with them selves and talk to the user
<div id="_mcePaste" style="overflow: hidden;width: 1px;height: 1px">OK, at the moment no-one is developing the program apart from myself.

But it struck me that if I documented a few things as if people were,

then I'd have a lot of stuff ready if ever I get a co-developer or

even hand on the project.

The Canal Planner situation has, I think, shown us the danger of a

project like this being all in the mind of one individual.

So what I'll be doing from time to time is documenting how I did

particular things, in a sort of "tutorial" way.  The first thing to do

is to start with an apology for the number of languages (big and

small) used in CanalPlanAC.  I thought it might be fun to document

them all - but don't let this put anyone off: you don't need all of

them at any one time.

*C - the Interpreter that underlies CanalPlanAC is written in C.  This

can remain unchanged for months, until I discover a bug or find the

need to add a feature right into the language.  What tends to happen

is that I write something in the scripting langauge but find it too

slow or too cumbersome, so add it as a language feature instead.

There is - as yet - no modular extensibility to the C: there are

about 35 thousand lines of C in 87 source files that I've written,

and a chunk more in various pieces of "foreign" code that are linked

in.

*CanalPlanAC scripting language.  I have no name for this language,

which can be invoked interactively by /cgi-bin/canal/ or to execute a

file as /cgi-bin/canal file.can.  This is a basic like language that deserves another dozen items on the syntax.  It was vaguely inspired by Superbasic which could give you a few pointers to some of the syntax.  Key things about it are:

**An intermediate typing system where all values are one of a number of types, and get coerced from one to the other when assigned.

**Support for associative arrays (called "lookup" tables) and lists

**Inline operators: this is a mixed blessing - a line like «if a contains "hello" then ...» is easy to read, but precedence sometimes goes wrong.  (So «print 'this is me and you' after 'me' contains 'you'» produces the whole string (because it parses as evalutate «'me' contains 'you'» which is 0, then returns the original string after character 0.

**Built-in comprehension of a waterways network with the ability to plan routes aroung it and travel along them.

**Built-in read/write of SQL, JSON and XML

*There are a few small bash scripts, mainly to kick off CanalPlan programs.

*There is the whole automake/autoconf nest of snakes in /source/ but that shouldn't need touching.

*Many web pages use Javascript (both home written and some appropriately licensed utilities) to do place name lookup, display maps etc.</div><img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/Rf5fyLfTBAI" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/canalplanac/2009/10/01/whats-under-the-bonnet-in-canalplanac-part-1-programming-languages/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/canalplanac/2009/10/01/whats-under-the-bonnet-in-canalplanac-part-1-programming-languages/</feedburner:origLink></item>
						<item>
				<title>Cats have feelings too</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/UqsWGpWbp6Q/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/09/16/cats-have-feelings-too/#comments</comments>
				<pubDate>Wed, 16 Sep 2009 10:02:03 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/09/16/cats-have-feelings-too/</guid>
                <description><![CDATA[It feels odd being in the house without Kathy, I know I spend a lot of time during the day by myself normally but its in the evenings that I really miss her. It seems odd cooking just for me and the evenings drag on and when it comes to bed time it really does hit home.

But I'm not the only one missing her. Most of the cats, like Chester and Munchkin, don't really seem to be bothered, and Chester only really gets bothered when we've got the suitcases out and mum and dad turn up because he knows something is going on. But Bandit really is missing her.

Bandit was a cat we didn't plan on having. When we went to get Pixie, who is a black cat, Bandit was the only kitten left from the litter who hadn't been adopted and he was the runt of the litter and so we took him home along with Pixie.

Here is a photo of him taken as soon as we got him home back in August 2006 (the fuzzy black in the background is Pixie) :

<a class="tt-flickr tt-flickr-Medium" title="Hello!" href="http://www.flickr.com/photos/steve_a/461579202/"><img class="alignnone" src="http://farm1.static.flickr.com/194/461579202_5e13b864e3.jpg" alt="Hello!" width="500" height="333" /></a>

Bandit, along with Pixie, is a quite photogenic and when he was settling in here he just gave us a lot of photo opportunities:

<a class="tt-flickr tt-flickr-Medium" title="Why, Hello!" href="http://www.flickr.com/photos/steve_a/461579228/"><img class="alignnone" src="http://farm1.static.flickr.com/221/461579228_1eeeed334d.jpg" alt="Why, Hello!" width="500" height="333" /></a>

<a class="tt-flickr tt-flickr-Medium" title="Yes????????" href="http://www.flickr.com/photos/steve_a/461579212/"><img class="alignnone" src="http://farm1.static.flickr.com/172/461579212_bc9d566ba9.jpg" alt="Yes????????" width="500" height="333" /></a>

Those being just two from a large collection of "cute" photos.

As Bandit grew (and boy did he grow) he really bonded with Kathy and sometimes he seems to behave more like a dog in that he followed Kathy round the house and he loved carrying things round in his mouth too. In the evenings after supper he often hopped up into Kathy's lap to get some attention and he "patty paws" her. Bandit is really Kathy's cat and he never grew out of the habits he showed as a kitten.

He's now three and is a big solid cat as can be seen from this recent picture where he is relaxing on the doormats we brought back from the boat for cleaning (the ears in the foreground are Pixie's)

<a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0074.jpg"><img class="alignnone size-medium wp-image-406" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0074-300x225.jpg" alt="Bandit on the mats" width="300" height="225" /></a>

He might be a big solid cat but he's really missing Kathy and when I go to bed at night he hops up on top of me and miaows and demands lots of attention. If I ignore him then he headbutts my hand or my arm until I give him tickles. If I put my arms under the covers then he lies on me and stretches out his left paw and pats me on the chin, and if I ignore that then he resorts to licking the end of my nose. Then when he's had enough tickles he goes to the bottom of the bed and goes to sleep down there. When Kathy is home he tends to sleep on her side of the bed.

Now I know that you'll probably just say that its a cat and he doesn't care where he gets his tickles from but its only in the early evening that his behaviour changes. During the day he's doing just what he does most days, sleeping on our bed or out in the utility room on the boat mats. Its when it gets to about 6:30 which is when Kathy usually home that he starts prowling round the house more and he miaows a lot more too.

Both Kathy and I know what he'll be like when she gets home, she wont be able to go anywhere in the house for days without him sticking to her like glue and any time she sits down he'll be there in her lap demanding attention.]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/SMbrOrytVRiUV_pyQsb1dF_sDUI/0/da"><img src="http://feedads.g.doubleclick.net/~a/SMbrOrytVRiUV_pyQsb1dF_sDUI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/SMbrOrytVRiUV_pyQsb1dF_sDUI/1/da"><img src="http://feedads.g.doubleclick.net/~a/SMbrOrytVRiUV_pyQsb1dF_sDUI/1/di" border="0" ismap="true"></img></a></p>It feels odd being in the house without Kathy, I know I spend a lot of time during the day by myself normally but its in the evenings that I really miss her. It seems odd cooking just for me and the evenings drag on and when it comes to bed time it really does hit home.

But I'm not the only one missing her. Most of the cats, like Chester and Munchkin, don't really seem to be bothered, and Chester only really gets bothered when we've got the suitcases out and mum and dad turn up because he knows something is going on. But Bandit really is missing her.

Bandit was a cat we didn't plan on having. When we went to get Pixie, who is a black cat, Bandit was the only kitten left from the litter who hadn't been adopted and he was the runt of the litter and so we took him home along with Pixie.

Here is a photo of him taken as soon as we got him home back in August 2006 (the fuzzy black in the background is Pixie) :

<a class="tt-flickr tt-flickr-Medium" title="Hello!" href="http://www.flickr.com/photos/steve_a/461579202/"><img class="alignnone" src="http://farm1.static.flickr.com/194/461579202_5e13b864e3.jpg" alt="Hello!" width="500" height="333" /></a>

Bandit, along with Pixie, is a quite photogenic and when he was settling in here he just gave us a lot of photo opportunities:

<a class="tt-flickr tt-flickr-Medium" title="Why, Hello!" href="http://www.flickr.com/photos/steve_a/461579228/"><img class="alignnone" src="http://farm1.static.flickr.com/221/461579228_1eeeed334d.jpg" alt="Why, Hello!" width="500" height="333" /></a>

<a class="tt-flickr tt-flickr-Medium" title="Yes????????" href="http://www.flickr.com/photos/steve_a/461579212/"><img class="alignnone" src="http://farm1.static.flickr.com/172/461579212_bc9d566ba9.jpg" alt="Yes????????" width="500" height="333" /></a>

Those being just two from a large collection of "cute" photos.

As Bandit grew (and boy did he grow) he really bonded with Kathy and sometimes he seems to behave more like a dog in that he followed Kathy round the house and he loved carrying things round in his mouth too. In the evenings after supper he often hopped up into Kathy's lap to get some attention and he "patty paws" her. Bandit is really Kathy's cat and he never grew out of the habits he showed as a kitten.

He's now three and is a big solid cat as can be seen from this recent picture where he is relaxing on the doormats we brought back from the boat for cleaning (the ears in the foreground are Pixie's)

<a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0074.jpg"><img class="alignnone size-medium wp-image-406" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0074-300x225.jpg" alt="Bandit on the mats" width="300" height="225" /></a>

He might be a big solid cat but he's really missing Kathy and when I go to bed at night he hops up on top of me and miaows and demands lots of attention. If I ignore him then he headbutts my hand or my arm until I give him tickles. If I put my arms under the covers then he lies on me and stretches out his left paw and pats me on the chin, and if I ignore that then he resorts to licking the end of my nose. Then when he's had enough tickles he goes to the bottom of the bed and goes to sleep down there. When Kathy is home he tends to sleep on her side of the bed.

Now I know that you'll probably just say that its a cat and he doesn't care where he gets his tickles from but its only in the early evening that his behaviour changes. During the day he's doing just what he does most days, sleeping on our bed or out in the utility room on the boat mats. Its when it gets to about 6:30 which is when Kathy usually home that he starts prowling round the house more and he miaows a lot more too.

Both Kathy and I know what he'll be like when she gets home, she wont be able to go anywhere in the house for days without him sticking to her like glue and any time she sits down he'll be there in her lap demanding attention.<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/UqsWGpWbp6Q" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/09/16/cats-have-feelings-too/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/09/16/cats-have-feelings-too/</feedburner:origLink></item>
						<item>
				<title>Getting to grips with Latitude</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/UNwXhpmq1BU/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/09/08/getting-to-grips-with-latitude/#comments</comments>
				<pubDate>Tue, 08 Sep 2009 13:16:53 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/09/08/getting-to-grips-with-latitude/</guid>
                <description><![CDATA[Warning: This post contains material of a technical and mathematical nature, if you start reading and feel dizzy or nauseous then stop reading immediately and go and lie down.

Google Latitude is an interesting little app which allows you to advertise your location. On the Android G1 the GoogleMaps application comes with the ability to update your Latitude location directly from the phone.

The usual way of displaying your Latitude location is using the iframe that Google provide which looks like this:

<iframe src="http://www.google.com/latitude/apps/badge/api?user=-2983480754731033286&amp;type=iframe&amp;maptype=roadmap" width="180" height="200" frameborder="0"> </iframe>

Part of the integration work that I've done to link the blogs here to my brother's CanalPlan website (which is based very loosely on work I did for my 'O' Level computer studies way back in 1981/82 - and yes we did actually have microcomputers back then) involved using his list of locations to allow you to insert links easily into the blog post . I then extended that to allow you to easily embed Google maps of those locations into your posts. For example [[CP:Wigan Pier|ksq4]]  :

[[CPGM:Wigan Pier|ksq4]]

So the next logical step was to link Latitude locations back to CanalPlan locations.

first of all I looked at scraping the contents of the iframe but its a complete mess, and apparently against the Google TOS, and I was struggling of finding a neat way of getting data from Latitude. Then I found that Google provide two "feeds" for third party applications (i.e. its acceptable under the TOS to take data). The support extracts in JSON and KMZ formats. I choose the JSON one (<code>http://www.google.com/latitude/apps/badge/api?user=-2983480754731033286&amp;type=json</code>)  because I'm already parsing JSON data from my brother's site so I could just re-use some of the code. So that's brilliant, I now have my Latitude and Longitude from Google Latitude and I have a list of Canalplan places with latitudes and longitudes so in the words of Aleksandr Orlov, Simples, just match the two and the problem is solved.

Actually its far from simples because the locations inside CanalPlan are for very specific points and the chance of ever being on exactly the same co-ordinates as the CanalPlan location are pretty damned slim, especially given that a lot of the locations in CanalPlan are derived from other data sources. But it would be really nice to able to show the nearest Canalplan location to your current Latitude location wouldn't it? Especially if you were on the boat and moving.

There is a solution: Geospatial functions, and I think I just head a couple of heads hitting tables.

I was lucky that I'm running the blogs on MySQL 5.x because it supports some basic Geospatial functions. These are functions that allow you to perform calculations on places or rather sets of places, in my case that's the latitude and longitude of two places. I had to create a new column for my places table (called lat_lng_point) which is of a special datatype called <code>point</code>, and then I had to populate that column with data calculated from the latitude and longitude for each place using the MySQL <code>GeomFromText</code>function which creates a very odd looking data item.

It might look very odd but its quite powerful because you can do some very interesting things with it. If you take two "points" created using <code>GeomFromText</code> you can find the "distance" between them using the <code>GLength</code> function.

So using the following bit of code:

<code>$findit="GeomFromText('Point(".($lat) ." ".($lng).")')";
$sql="SELECT place_name,lat,`long`,GLength(LineStringFromWKB(LineString(AsBinary(lat_lng_point), AsBinary('".$findit."')))) AS distance FROM canalplan_codes ORDER BY distance ASC LIMIT 1";
$res = mysql_query($sql);
</code>

We can take the latitude ($lat) and longitude ($lng) from the JSON feed and find the nearest CanalPlan location that matches it.

At the time of writing this post the code (with a few extra bits to make it look nice) produces:
<code>
Finding places closest to My current Latitude location at Cheltenham, Gloucestershire, UK (51.9031645,-2.0471622)</code>

<code>Avon Lock (51.9962,-2.15681) is 0.14382 from Cheltenham, Gloucestershire, UK </code>

Now no doubt you're scratching your head trying to work out what that distance is. Well its a distance expressed in degrees which is pretty meaningless to people like us.

So that is how things stand now, and that's why the little Latitude Widget on the right hand bar has a little bit of text underneath it saying what the nearest Canalplan location is.

What comes next? 

Well possibly implementing a "real" distance. As I said the distance given is in degrees so we can either trust that its right or we can recalculate from scratch.  The calculation for this is quite simple (!) :

<code>gcdr=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))</code>

This gives the "Great Circle Distance" between the two points (lat1/lon1, lat2/lon2) in degrees. You then convert this to nautical miles by multiplying it by 60, and then finally multiplying that by 1852 you get the distance in metres which I can then convert into one of several "nicer" formats.  So it could say:

Avon Lock is a distance of 9 miles, 7¼ flg from Cheltenham, Gloucestershire, UK

The other, much easier, thing to do is to create a new widget that replaces the Google Latitude iframe with a mini Googlemap with your nearest CanalPlan location on it (and saying where you actually are under it).

Well I think everyone's brains are probably hurting now, so I think I'll go for a walk.

Class Dismissed!]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/tXHI92o3gE0q7O5cyKIFr61P2xw/0/da"><img src="http://feedads.g.doubleclick.net/~a/tXHI92o3gE0q7O5cyKIFr61P2xw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/tXHI92o3gE0q7O5cyKIFr61P2xw/1/da"><img src="http://feedads.g.doubleclick.net/~a/tXHI92o3gE0q7O5cyKIFr61P2xw/1/di" border="0" ismap="true"></img></a></p>Warning: This post contains material of a technical and mathematical nature, if you start reading and feel dizzy or nauseous then stop reading immediately and go and lie down.

Google Latitude is an interesting little app which allows you to advertise your location. On the Android G1 the GoogleMaps application comes with the ability to update your Latitude location directly from the phone.

The usual way of displaying your Latitude location is using the iframe that Google provide which looks like this:

<iframe src="http://www.google.com/latitude/apps/badge/api?user=-2983480754731033286&amp;type=iframe&amp;maptype=roadmap" width="180" height="200" frameborder="0"> </iframe>

Part of the integration work that I've done to link the blogs here to my brother's CanalPlan website (which is based very loosely on work I did for my 'O' Level computer studies way back in 1981/82 - and yes we did actually have microcomputers back then) involved using his list of locations to allow you to insert links easily into the blog post . I then extended that to allow you to easily embed Google maps of those locations into your posts. For example [[CP:Wigan Pier|ksq4]]  :

[[CPGM:Wigan Pier|ksq4]]

So the next logical step was to link Latitude locations back to CanalPlan locations.

first of all I looked at scraping the contents of the iframe but its a complete mess, and apparently against the Google TOS, and I was struggling of finding a neat way of getting data from Latitude. Then I found that Google provide two "feeds" for third party applications (i.e. its acceptable under the TOS to take data). The support extracts in JSON and KMZ formats. I choose the JSON one (<code>http://www.google.com/latitude/apps/badge/api?user=-2983480754731033286&amp;type=json</code>)  because I'm already parsing JSON data from my brother's site so I could just re-use some of the code. So that's brilliant, I now have my Latitude and Longitude from Google Latitude and I have a list of Canalplan places with latitudes and longitudes so in the words of Aleksandr Orlov, Simples, just match the two and the problem is solved.

Actually its far from simples because the locations inside CanalPlan are for very specific points and the chance of ever being on exactly the same co-ordinates as the CanalPlan location are pretty damned slim, especially given that a lot of the locations in CanalPlan are derived from other data sources. But it would be really nice to able to show the nearest Canalplan location to your current Latitude location wouldn't it? Especially if you were on the boat and moving.

There is a solution: Geospatial functions, and I think I just head a couple of heads hitting tables.

I was lucky that I'm running the blogs on MySQL 5.x because it supports some basic Geospatial functions. These are functions that allow you to perform calculations on places or rather sets of places, in my case that's the latitude and longitude of two places. I had to create a new column for my places table (called lat_lng_point) which is of a special datatype called <code>point</code>, and then I had to populate that column with data calculated from the latitude and longitude for each place using the MySQL <code>GeomFromText</code>function which creates a very odd looking data item.

It might look very odd but its quite powerful because you can do some very interesting things with it. If you take two "points" created using <code>GeomFromText</code> you can find the "distance" between them using the <code>GLength</code> function.

So using the following bit of code:

<code>$findit="GeomFromText('Point(".($lat) ." ".($lng).")')";
$sql="SELECT place_name,lat,`long`,GLength(LineStringFromWKB(LineString(AsBinary(lat_lng_point), AsBinary('".$findit."')))) AS distance FROM canalplan_codes ORDER BY distance ASC LIMIT 1";
$res = mysql_query($sql);
</code>

We can take the latitude ($lat) and longitude ($lng) from the JSON feed and find the nearest CanalPlan location that matches it.

At the time of writing this post the code (with a few extra bits to make it look nice) produces:
<code>
Finding places closest to My current Latitude location at Cheltenham, Gloucestershire, UK (51.9031645,-2.0471622)</code>

<code>Avon Lock (51.9962,-2.15681) is 0.14382 from Cheltenham, Gloucestershire, UK </code>

Now no doubt you're scratching your head trying to work out what that distance is. Well its a distance expressed in degrees which is pretty meaningless to people like us.

So that is how things stand now, and that's why the little Latitude Widget on the right hand bar has a little bit of text underneath it saying what the nearest Canalplan location is.

What comes next? 

Well possibly implementing a "real" distance. As I said the distance given is in degrees so we can either trust that its right or we can recalculate from scratch.  The calculation for this is quite simple (!) :

<code>gcdr=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))</code>

This gives the "Great Circle Distance" between the two points (lat1/lon1, lat2/lon2) in degrees. You then convert this to nautical miles by multiplying it by 60, and then finally multiplying that by 1852 you get the distance in metres which I can then convert into one of several "nicer" formats.  So it could say:

Avon Lock is a distance of 9 miles, 7¼ flg from Cheltenham, Gloucestershire, UK

The other, much easier, thing to do is to create a new widget that replaces the Google Latitude iframe with a mini Googlemap with your nearest CanalPlan location on it (and saying where you actually are under it).

Well I think everyone's brains are probably hurting now, so I think I'll go for a walk.

Class Dismissed!<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/UNwXhpmq1BU" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/09/08/getting-to-grips-with-latitude/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/09/08/getting-to-grips-with-latitude/</feedburner:origLink></item>
						<item>
				<title>Summer is over... it's official</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/IPtBw2Zv5IM/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/09/01/summer-is-over-its-official/#comments</comments>
				<pubDate>Tue, 01 Sep 2009 14:13:08 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/09/01/summer-is-over-its-official/</guid>
                <description><![CDATA[September 1<sup>st</sup> and Summer is now officially over.

How do I know? Do I have some special Almanac that tells me? Is it all based on folk lore? Is it because the schools went back today?

Nope, its none of those.

I know Summer is over because when I went to our local Sainsbury's supermarket, to pick up a few things, all the "Summer" related products such as BBQs, charcoal, lighter fluid, disposable picnic plates etc., have all vanished. Gone as if they never existed. All gone and replaced with something else.

So what "Season" is it now? Is it Autumn, <a href="http://www.phrases.org.uk/meanings/313050.html" target="_blank">Season of mists and mellow fruitfulness</a> ? No... I'm afraid not.

It's "Back to School" Season. What ever that is. Not everyone has children of school age and this obsession shops have with things like this just depresses me.

Still it could be worse, it could be Christmas (I think that's in a couple of weeks).]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/ge-yJlsoD7zYShl5FY77ieY7hsM/0/da"><img src="http://feedads.g.doubleclick.net/~a/ge-yJlsoD7zYShl5FY77ieY7hsM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ge-yJlsoD7zYShl5FY77ieY7hsM/1/da"><img src="http://feedads.g.doubleclick.net/~a/ge-yJlsoD7zYShl5FY77ieY7hsM/1/di" border="0" ismap="true"></img></a></p>September 1<sup>st</sup> and Summer is now officially over.

How do I know? Do I have some special Almanac that tells me? Is it all based on folk lore? Is it because the schools went back today?

Nope, its none of those.

I know Summer is over because when I went to our local Sainsbury's supermarket, to pick up a few things, all the "Summer" related products such as BBQs, charcoal, lighter fluid, disposable picnic plates etc., have all vanished. Gone as if they never existed. All gone and replaced with something else.

So what "Season" is it now? Is it Autumn, <a href="http://www.phrases.org.uk/meanings/313050.html" target="_blank">Season of mists and mellow fruitfulness</a> ? No... I'm afraid not.

It's "Back to School" Season. What ever that is. Not everyone has children of school age and this obsession shops have with things like this just depresses me.

Still it could be worse, it could be Christmas (I think that's in a couple of weeks).<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/IPtBw2Zv5IM" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/09/01/summer-is-over-its-official/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/09/01/summer-is-over-its-official/</feedburner:origLink></item>
						<item>
				<title>All hands on Deck</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/ZKJ0qEolap0/</link>
				<comments>http://blogs.canalplan.org.uk/steve/2009/09/01/all-hands-on-deck/#comments</comments>
				<pubDate>Tue, 01 Sep 2009 09:25:51 +0000</pubDate>
				<dc:creator>Steve</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/steve/2009/09/01/all-hands-on-deck/</guid>
                <description><![CDATA[Last weekend Nick and I headed up to the boat to do some work on it. The deck boards on the boat are made out of plywood and they get wet and once water gets in on the cut edge they start to break down, and the starboard deck which is the one that we use a lot to get on and off the boat (and also gets more water running over it)  had gone a little mushy and was starting to fall apart:

<a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0065.jpg"><img class="alignnone size-medium wp-image-354" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0065-300x225.jpg" alt="img_0065" width="300" height="225" /></a>

The last thing we wanted was for someone to jump onto the back deck at a lock and go through the deck into the engine well so we'd decided to replace it. The decks have been replaced twice since the boat was launched in 1986 and the last time they were done was back in 2000/2001. As you might have noticed the side panels aren't square and cutting a piece of ply that big to that sort of shape isn't easy, and its not cheap to buy either!

So we'd discussed alternatives and decided to go with timber planks which had been pressure treated against rot. There were several reasons for this:
<ul>
	<li>Hopefully they should last longer than ply</li>
	<li>They would be cheaper as ply, or no more expensive</li>
	<li>Its easier to cut one plank to the odd taper than a sheet of ply and it if goes wrong then you've only wasted one plank.</li>
	<li>A solid cut edge will be less permeable to water than the cut edge of the ply</li>
	<li>Easier to repair, if a plank gets damaged we can simply replace it.</li>
</ul>
So we went to Wickes and spent about £60 on timber planks and beams and screws, bolts and brackets and early on Saturday morning we took a screwdriver, our trusted Dunlop tyre iron and our hands to the old deck and ripped it up exposing the top of the starboard fuel tank and the batteries:

<a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0066.jpg"><img class="alignnone size-medium wp-image-355" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0066-300x225.jpg" alt="img_0066" width="300" height="225" /></a>

The first thing we did was clean the piles of grit blast off the top of the tank - it gets everywhere and my recommendation to anyone is DONT ever grit blast your boat unless you want to be finding the stuff for years.

Once we'd done that, and had a coffee, we put wooden beam down the side of the drain channel and then built a timber frame up which would provide support for the planks. We had to do this slightly differently than the way we'd planned it in our heads because we couldn't remember just how things were arranged under the deck, but the principle was the sane:

<a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0067.jpg"><img class="alignnone size-medium wp-image-356" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0067-225x300.jpg" alt="img_0067" width="225" height="300" /></a>

Then it was a matter of cutting each plank to length and fixing them in place with lots of screws and lots of frame sealant to stop water creeping through it:

<a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0068.jpg"><img class="alignnone size-medium wp-image-357" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0068-300x225.jpg" alt="img_0068" width="300" height="225" /></a>

As the sealant needed to cure and as it was now late afternoon we called it a day, got cleaned up, had something to eat and headed off to the pub.

Sunday morning we got up early and we took some floor paint which we diluted to make it easier to apply onto the raw wood and we painted the deck:

<a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0072.jpg"><img class="alignnone size-medium wp-image-351" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0072-225x300.jpg" alt="img_0072" width="225" height="300" /></a><a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0071.jpg"><img class="size-medium wp-image-359 alignright" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0071-225x300.jpg" alt="img_0071" width="225" height="300" /></a>

What these last two photos show is that the two middle deck boards really need replacing next. As these two are the ones that sit over the engine, and have to be lifted to check the oil and coolant and to access the weedhatch and sterngland, we'll probably use ply wood for these two but we might put a cross strut on the bigger board to stop it flexing as much as it does. The other side deck is slightly more complicated because its got the fuel filler hose and the control panel on it. But now we pretty much know what to do we know that its another days work for the side panel (and we have all the timber we need for that) and other one for the middle panels]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/g2MEzzHgrjQgnx1zijrzbZ4SXFY/0/da"><img src="http://feedads.g.doubleclick.net/~a/g2MEzzHgrjQgnx1zijrzbZ4SXFY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/g2MEzzHgrjQgnx1zijrzbZ4SXFY/1/da"><img src="http://feedads.g.doubleclick.net/~a/g2MEzzHgrjQgnx1zijrzbZ4SXFY/1/di" border="0" ismap="true"></img></a></p>Last weekend Nick and I headed up to the boat to do some work on it. The deck boards on the boat are made out of plywood and they get wet and once water gets in on the cut edge they start to break down, and the starboard deck which is the one that we use a lot to get on and off the boat (and also gets more water running over it)  had gone a little mushy and was starting to fall apart:

<a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0065.jpg"><img class="alignnone size-medium wp-image-354" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0065-300x225.jpg" alt="img_0065" width="300" height="225" /></a>

The last thing we wanted was for someone to jump onto the back deck at a lock and go through the deck into the engine well so we'd decided to replace it. The decks have been replaced twice since the boat was launched in 1986 and the last time they were done was back in 2000/2001. As you might have noticed the side panels aren't square and cutting a piece of ply that big to that sort of shape isn't easy, and its not cheap to buy either!

So we'd discussed alternatives and decided to go with timber planks which had been pressure treated against rot. There were several reasons for this:
<ul>
	<li>Hopefully they should last longer than ply</li>
	<li>They would be cheaper as ply, or no more expensive</li>
	<li>Its easier to cut one plank to the odd taper than a sheet of ply and it if goes wrong then you've only wasted one plank.</li>
	<li>A solid cut edge will be less permeable to water than the cut edge of the ply</li>
	<li>Easier to repair, if a plank gets damaged we can simply replace it.</li>
</ul>
So we went to Wickes and spent about £60 on timber planks and beams and screws, bolts and brackets and early on Saturday morning we took a screwdriver, our trusted Dunlop tyre iron and our hands to the old deck and ripped it up exposing the top of the starboard fuel tank and the batteries:

<a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0066.jpg"><img class="alignnone size-medium wp-image-355" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0066-300x225.jpg" alt="img_0066" width="300" height="225" /></a>

The first thing we did was clean the piles of grit blast off the top of the tank - it gets everywhere and my recommendation to anyone is DONT ever grit blast your boat unless you want to be finding the stuff for years.

Once we'd done that, and had a coffee, we put wooden beam down the side of the drain channel and then built a timber frame up which would provide support for the planks. We had to do this slightly differently than the way we'd planned it in our heads because we couldn't remember just how things were arranged under the deck, but the principle was the sane:

<a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0067.jpg"><img class="alignnone size-medium wp-image-356" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0067-225x300.jpg" alt="img_0067" width="225" height="300" /></a>

Then it was a matter of cutting each plank to length and fixing them in place with lots of screws and lots of frame sealant to stop water creeping through it:

<a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0068.jpg"><img class="alignnone size-medium wp-image-357" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0068-300x225.jpg" alt="img_0068" width="300" height="225" /></a>

As the sealant needed to cure and as it was now late afternoon we called it a day, got cleaned up, had something to eat and headed off to the pub.

Sunday morning we got up early and we took some floor paint which we diluted to make it easier to apply onto the raw wood and we painted the deck:

<a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0072.jpg"><img class="alignnone size-medium wp-image-351" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0072-225x300.jpg" alt="img_0072" width="225" height="300" /></a><a href="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0071.jpg"><img class="size-medium wp-image-359 alignright" src="http://blogs.canalplan.org.uk/steve/files/2009/09/img_0071-225x300.jpg" alt="img_0071" width="225" height="300" /></a>

What these last two photos show is that the two middle deck boards really need replacing next. As these two are the ones that sit over the engine, and have to be lifted to check the oil and coolant and to access the weedhatch and sterngland, we'll probably use ply wood for these two but we might put a cross strut on the bigger board to stop it flexing as much as it does. The other side deck is slightly more complicated because its got the fuel filler hose and the control panel on it. But now we pretty much know what to do we know that its another days work for the side panel (and we have all the timber we need for that) and other one for the middle panels<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/ZKJ0qEolap0" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/steve/2009/09/01/all-hands-on-deck/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/steve/2009/09/01/all-hands-on-deck/</feedburner:origLink></item>
						<item>
				<title>New Domain</title>
				<link>http://feedproxy.google.com/~r/CanalplanBlogsMasterSiteFeed/~3/gAzCRUEkq6g/</link>
				<comments>http://blogs.canalplan.org.uk/blog/2009/08/31/new-domain/#comments</comments>
				<pubDate>Mon, 31 Aug 2009 21:53:05 +0000</pubDate>
				<dc:creator>Admin</dc:creator>
				<guid isPermaLink="false">http://blogs.canalplan.org.uk/blog/2009/08/31/new-domain/</guid>
                <description><![CDATA[As part of the streamlining of lots of stuff Canalplan Blogs has now moved to a new domain name.

From now on you can find us at <a href="http://blogs.canalplan.org.uk" target="_blank">http://blogs.canalplan.org.uk</a>

Hopefully all your old links will still work but you should see the new URL in the navigation bar.

So can you please update your book marks.

If you find any problems please let me know.]]></description>
                <content:encoded><![CDATA[
<p><a href="http://feedads.g.doubleclick.net/~a/1cUeu8mJbdkXodw3Irf3UJew1fs/0/da"><img src="http://feedads.g.doubleclick.net/~a/1cUeu8mJbdkXodw3Irf3UJew1fs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/1cUeu8mJbdkXodw3Irf3UJew1fs/1/da"><img src="http://feedads.g.doubleclick.net/~a/1cUeu8mJbdkXodw3Irf3UJew1fs/1/di" border="0" ismap="true"></img></a></p>As part of the streamlining of lots of stuff Canalplan Blogs has now moved to a new domain name.

From now on you can find us at <a href="http://blogs.canalplan.org.uk" target="_blank">http://blogs.canalplan.org.uk</a>

Hopefully all your old links will still work but you should see the new URL in the navigation bar.

So can you please update your book marks.

If you find any problems please let me know.<img src="http://feeds.feedburner.com/~r/CanalplanBlogsMasterSiteFeed/~4/gAzCRUEkq6g" height="1" width="1"/>]]></content:encoded>
				<wfw:commentRss>http://blogs.canalplan.org.uk/blog/2009/08/31/new-domain/feed/</wfw:commentRss>
			<feedburner:origLink>http://blogs.canalplan.org.uk/blog/2009/08/31/new-domain/</feedburner:origLink></item>
			</channel>
</rss>
