Steve's Ramblings

  • Home
  • About
  • LastFM Widgets
  • Post By Mail
  • Site Search
  • Wordbooker
Witterings from the Site owner

← So much for Mobile broadband
Still Alive →

Revisiting “old” Code

May 19th, 2010 by Steve and tagged facebook, php, Wordbooker, wordpress


Nick commented once about some of the code in CanalPlan AC 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 Wordbooker 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.

  • Share this:
  • Digg
  • Reddit
  • Print
  • StumbleUpon
  • Press This
  • Email

Category Computing, Witterings |



4 Responses to “ Revisiting “old” Code ”

  1.    Don West Says:
    May 20th, 2010 at 8:51 am

    So is 1.7.9 the result of this? I ask because I noticed a new version was available thru the dashboard and I upgraded this a.m. while fighting insomnia lol!
    I was looking to find out what had changed and found this post.

  2.    Steve Says:
    May 20th, 2010 at 11:39 am

    1..9 (or it might morph into 2.0) will be the result.

    1.7.9 fixed some minor bugs and is really a wrap up before 1.8 (Oauth) comes out early next week.

  3.    Will Sitch Says:
    May 22nd, 2010 at 5:40 pm

    Hi Steve,

    I’ve been using Wordbook for a while, I even got Rob Tsai to add some code to support WPG2 tags for images. I like the idea of cross-posting comments and I like that you’re taking his code and running with it!

    I’ll wait until you’ve got Oauth all figured out before I switch over, but it sounds like you’re putting in a lot of work. From someone in the peanut gallery: “thanks!”

    Can I encourage you to recognize and support WPG2 tags as image identifiers? The code I added can be found by searching the latest wordbook.php for “wpg2″. I’ve also added it here:

    function wordbook_fbclient_publishaction(…) {
    …
    /* Pull out image tags. */
    $wpg2_g2path = get_option(‘wpg2_g2paths’);
    if ($wpg2_g2path) {
    $g2embeduri = $wpg2_g2path['g2_embeduri'];
    if ($g2embeduri) {
    preg_match_all(‘/(.*?) $g2embeduri
    . ‘?g2_view=’
    . ‘core.DownloadItem’
    . “&g2_itemId=$wpgtag”,
    ‘href’ => $post_link,
    );
    }
    }
    }
    }

    Thanks much,
    Will

    •    Steve Says:
      May 23rd, 2010 at 1:09 am

      As I actually scrape the parsed post (i.e. a copy of what is posted to the browser) for images, rather than the stored text it might not actually need this. I’ve never used WPG2 as its not WPMU2 compatible as far as I’m aware and my primary dev environment is WPMU.

  • Facebook Status


     FB photo for Stephen Atty


    Stephen Atty : OK - where's the Lamba key on my keyboard....
    (Sat Jan 21, 4:49 pm).

  •  

  • The Old Stuff

    • October 2010
    • July 2010
    • May 2010
    • April 2010
    • February 2010
    • January 2010
    • December 2009
    • November 2009
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
    • September 2007
    • August 2007
    • July 2007
    • June 2007
    • May 2007
    • April 2007
    • March 2007
    • February 2007
    • December 2006
    • October 2006
    • September 2006
    • August 2006
    • July 2006
    • December 2005
    • November 2005
    • August 2005
    • February 2005
    • January 2005
    • December 2004
  • Site Wide Tags


    3G 93 95 accident accounts Add new tag alcohol allergy advice alone alternator america android animal anniversary apache augusta autherley bank basketball beer Beeston benefits birmingham birthday blogging blogs boat boating Bob Geldof Boscastle boston brakes Braunston brewood BSS Bude builders C cable calendar camsigh canalplan canalplan AC car crash car park cars Cast List casualty Cats Challenger chavs cheese cheltenham Chester christian louboutin for sale christian louboutin on sale christian louboutin sale online Christmas cinco de mayo clearsilver coast code coding cold Computer Computing cooker CPRS crackers curry customer service dead depression diet diy dns Download dowód e-commerce easter eli stone elvis email enhancement extension facebook fashion jewelry favourites fish floods food forums Fraud fridge funding g1 gailey garage garden gas GCHQ General Options geospatial gloucester gnosall gold cup goldstone Goodies google Googlemaps granny buttons graph API grub street guinness hackers hallowell Heathrow holiday holidays home home mooring hoover hotel Importing integration intercontinental internet Internet Explorer irish Javascript jen jewellery Jill Joke json kathy kennebunk kestrel kitchen korea ladykat Last.FM latitude lawn leeching lighthouses linux ll bean lonely longitude lunch maine malvern manage routes maps market drayton maths mexican microsoft midges mintball mobile mooring mortgage MOT moving mozart MP Music mystery na Nantwich national hunt netscape new domain new features new server nhs norbury npower ogunquit painting paprika party penkridge petition photos php phpbb pickle plugin Plugins poke in the eye police portland post by email Pożyczka pringles programming pub night

    Donate

    If you've found anything useful on here and want to say thanks then please feel free:



    WPMUDEV

    WordPress MU, WPMU and BuddyPress plugins, themes and support at WPMU DEV

    Snapshots

    Enhanced with Snapshots
  •  


© 2012 Steve's Ramblings using Dignity theme by themebox

RSS Entries and RSS Comments.

Provided by WPMU DEV -The WordPress Experts
Hosted by Canalplan Blogs


Server uptime: 66 day(s), 21 hour(s) and 33 minute(s) | Server Load: 0.14, 0.21, 0.18

Canalplan Interlinking provided by Canalplan AC Plugin

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.