Facebook Note Comments to Wordpress Comments
As some people might know, or might not, Facebook has the ability to automatically re-post your blog posts into Facebook under their Note application. You can do this for a single blog only at a time, for the settings page for this in Facebook see the Import a Blog page.
After having my posts imported into Facebook for a while people occasionally comment on them, and I had wondered if there was a way to have them displayed in my blog. As people seem to comment more on the Notes in Facebook rather than the real blog articles themselves. After a quick bit of searching around, I found a WordPress plugin, made originally by Adam Hill, and has been updated by Thomas Albright.
So I downloaded that, then uploaded to my blog and with glee entered my settings and pressed the import comments button. To my disappointment the plugin didn’t work . I thought “well ok, its coded in PHP, so lets see how it works”. I tell you this wasn’t a simple to figure out, as its more complex than it appears.
In the end after spending some time playing around with it, and having to constantly log in and out of Facebook to test I got it working. The fix itself was very simple, it wasn’t so much a code error, or a major change to the Facebook site that caused it to break. Obviously Facebook developers had been alerted to this plugin and decided that they didn’t want this, quite frankly really quite nice plugin, to work any more. So they decided to start tinkering with things. Nothing drastic, and nothing that changes the way that the page is shown to the user. All the HTML code remained unchanged except for some very.. VERY.. sly changes.
Now before you jump to conclusions, it wasn’t extra div’s, extra line breaks here or there, or even re-structuring the code. This adjustment had to be done in a way so that the original coder would look at the source of the page and see no modifications, and that the only difference was that before the plugin worked, and now it doesn’t. So what’s the easiest way to do that?
Whitespace! The simple addition of a single space in select parts of the HTML markup caused various and important regex’s within the plugin to fail, and therefore would no longer be able to read and distinguish comments on Facebook. So all it took was to see what they were before, easily done by examining the regexp’s, and then comparing that to the current source code you see on the site. From that you then fix the regexp for this new tinkered-with-code and away it goes again!
So a hello goes out to the random Facebook developer who ends up reading this as they get ordered to fudge it again. You could however, instead of doing that again, add functions to the Facebook API so it could be done legitimately!
If you wish to test this plugin, simply reply to this note on Facebook and it will appear on the article page within about an hour. (It updates on the half-past the hour)
Anyway, if you want the new fixed version of this plugin you can download it just below…
Download
Download - WordPress Facebook Notes Plugin
Share This
[…] Facebook Note Comments to Wordpress Comments - Edited and Updated ‘Limi’s Concept Zone’. […]
I couldn’t get this to import. Has anyone had any luck lately?
Try updating to the new version 0.3 if you haven’t already.
When you do a manual import do you get any errors?
So I played with it a bit, and got it running. A couple of things:
I forgot to change the permissions on the file to 755 in the plugins directory.
I was confused as to which version I was using, since the data at the top of the script still has v0.2 noted.
I am using the wordpress SVN 6028 and get the following error when running manually:
"Post Title"Comment by John Doe
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND a.comment_approved = '1' AND a.comment_author LIKE 'John Doe (via Faceboo' at line 1]
SELECT COUNT(a.comment_ID) FROM wp_comments a WHERE a.comment_post_id = AND a.comment_approved = '1' AND a.comment_author LIKE 'John Doe (via Facebook)'
not in database.
Adding to Wordpress... Done!
They don’t seem to be relating to the original post. Example, check out http://www.erikankrom.com
Looks to be here:
a.comment_post_id = AND a.comment_approved = '1'$thisquery = sprintf("SELECT COUNT(a.comment_ID) FROM %s a WHERE a.comment_post_id = %s AND a.comment_approved = '1' AND a.comment_author LIKE '%s'", $wpdb->comments, $comment_post_ID, $comment_author);I am not great with programming, I just snip here and there, so I’ll leave it to you to disect.
I’ve added some more checking code to make sure that shouldn’t be able to happen any more. Download the 0.3 zip file again and it should work ok.
Has anyone got this working lately ?
My manual import doesnt seem to throw an error, but it just … doesnt do anything…
Just sits there
Manually importing comments …
same problem as choco…. nothing happens after that and no comments are imported.
It’s not working for me either.
Sorry for the delay in reply, do you all have curl (program not php extension) installed? This is a unix only script. If you do have curl installed and its not working where is it installed?
“locate curl”
The first version of this plugin worked at one point, so I am going to assume I have curl installed.
I haven’t been able to get this to work yet either. I tried both versions (0.2 + 0.3).
Hey Limi, I just upgraded to Wordpress 2.3 and installed your plugin. Installation was fine, and it doesn’t break anything, but I figured that while it does import the comments into the database, it doesn’t attach them to the relevant post, leaving the poor comments floating around without a parent.
You’re probably busy, but if you could point me in the right direction to fix it I’d really appreciate it. ^^
The query where it looks up the post, is done on like 135. Although I can probably guess why it’s not working on your blog, you aren’t using the nice url’s like I do here. eg. “YYYY/MM/DD/Slug” So it’s got nothing to look it up on. Try activating that and trying again.
Hey^^
I tried changing the permalink structure to the format you suggested, but it still didn’t work.
I took a look at the SQL database and noticed that while I commented on two different notes on facebook, both comments got assigned to post #0 when I manually imported them.
With the update to the permalink structure it may only work on new posts you make, as Facebook will still be using the old links.
Facebook has released their API. So now building the plugin could be made with pervalence for the future
I found these to links:
http://developers.facebook.com/phpembed/
http://fasterfuture.blogspot.com/2007/10/open-to-really-big-opportunity.html
Actually I dn’t no much about these things, but Im guessing it is of importance to the facebook plugin. - if not, just ignore this.
I am with Brian, I have upgraded to the latest SVN version of wordpress (10/24, post 2.3 upgrade). I have the same permalink structure you suggested, and the same that is on your blog here. The problem is, the admin site shows my comments being related to the correct post in the display of the admin page after the export, but the actual comments are not linked to the correct comments.
How is the comparison done to match them? It looks like the id of the wordpress post is not getting assigned to the imported comment correctly. See my page for an example showing recent comments, but no comments on the post page itself.
This script still seems to hang on importing comments with me. If my permalink structure is wrong I’d assume that it would finish and let me know that 0 comments were found.
But it just hangs.