Steve's Ramblings

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

← Posting to WordPress MU by Email Part 2
WordPress and Facebook Part five →

WordPress and Facebook – Part 4

October 28th, 2009 by Steve and tagged coding, facebook, programming, wordbook, wordpress, WPMU


Back in August I wrote about the Wordbook plugin for WordPress which basically replicates posts from your own hosted WordPress (or WordPress MU) blog into your Facebook 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 didn’t 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 Feed.publishUserAction 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 stream.publish API call instead. That returns the Post ID and then you can simply get the comments by using Stream.getComments 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 Here it is

Some quick notes on Upgrading from the existing Wordbook plugin.

  • 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. DONT 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!

Debugging.
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.

Caveats

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 Wordbook Page

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

Category Computing |



16 Responses to “ WordPress and Facebook – Part 4 ”

  1.    Stephen Atty Says:
    October 28th, 2009 at 4:34 pm

    Well will you look at that, I managed to miss one of the unicode conversions!

  2.    Alex Says:
    October 28th, 2009 at 5:25 pm

    Hi Stephen ,

    I am downloading and will do a fresh install. I will let you know what the result is after

    Alex Duvot ( from FB)

  3.    Alex Says:
    October 28th, 2009 at 9:28 pm

    Wordbook failed to communicate with Facebook for testing wordpress to facebook 2: method = stream.publish, error_code = 200 (Permissions error). Your blog is OK, but Facebook didn’t get the update.

  4.    Steve Says:
    October 28th, 2009 at 9:30 pm

    Thats’ a FB API error (200) which indicates insufficient permissions, not a lot I can do about that unfortunately unless its generic and caused by a change in the permissions needed to post

    But I’ve seen Facebook throwing account errors this evening

    If you go to your Facebook Application Settings and select to show “Granted additional permissions” you should see Wordbook in all the categories including Publish to streams and Access streams.

  5.    Alex Says:
    October 29th, 2009 at 1:31 am

    thanks for the fix
    resolved

    This is the best plugin I have seen or used so far.

  6.    Steve Says:
    October 29th, 2009 at 8:13 am

    Alex, glad the fix worked. I’ll add it into the upgrade notes later today.

  7.    Fatima Says:
    November 8th, 2009 at 6:23 pm

    Hi Steve,

    Tried to download it but the zip file is invalid?? Won’t let me open it up and if it does, it extracts a 0kb doc.

    Thanks.

  8.    Steve Says:
    November 8th, 2009 at 6:47 pm

    How very odd, I’ll look into it. However the static page for it works:

    http://blogs.canalplan.org.uk/steve/wordbook/

  9.    Fatima Says:
    November 8th, 2009 at 7:21 pm

    Hi Steve, now it downloads a file ~250kb in size but when I open it up in WinRar it gives me an error and says “unexpected end of compilation”!

    Thanks!

  10.    Steve Says:
    November 8th, 2009 at 7:26 pm

    Can you use winzip or anything else? I’m in the middle of things on my Linux Laptop (actually working on more enhancements to the plugin) so I can’t check if its OK from Vista.

  11.    Fatima Says:
    November 8th, 2009 at 7:30 pm

    Tried another program and still coming up as invalid!

  12.    Steve Says:
    November 8th, 2009 at 7:52 pm

    I’ve just booted up into Vista and Windows unpacked it fine. I also downloaded and installed the demo of Winrar and it opened it fine as well.

  13.    Fatima Says:
    November 8th, 2009 at 11:40 pm

    Sorry still getting errors in both WinRar and opening with Windows.

  14.    Steve Says:
    November 9th, 2009 at 8:30 am

    Thats very odd. Have you tried clearing out any copies you’ve downloaded and deleting your internet cache?

    Also I assume you’re saving the file to your computer rather than trying to unzip it on the fly?

  15.    M.K. Hobson Says:
    November 24th, 2009 at 5:02 am

    Hi: Thanks for your hard work! I installed this plugin and immediately got a notice that a new version of the plugin (0.14.10) is available.Have the same fixes been integrated to 0.14.10? Or are these options only in 0.14.08?

    Thanks again,
    Mary

  16.    Steve Says:
    November 24th, 2009 at 2:41 pm

    My forked version isn’t in the WP extensions repository. I’ve rolled up the latest changes in the “core” version into my forked version. So if you’ve installed my fork then you need to ignore the version notification on the plugin page and use the check on the plugin options page instead.

  • 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), 22 hour(s) and 00 minute(s) | Server Load: 0.10, 0.15, 0.16

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.