Saturday, September 8, 2012

Facebook plug-in for Wordpress

Completing the Facebook Plugin installation is no easy task as the last part is to submit the 'Publish' action to allow Wordpress to auto publish posts. If you're having trouble here is :

How to Publish to Timeline

Review the official instructions from Facebook first:

There are additional instructions here that helped me.

However, the code used in there did not work for me and failed.  After many hours spent playing around with the code I have the following:

<html xmlns="" dir="ltr" lang="en-US"
<head prefix="og: fb: article:">
<title>OG Tutorial App</title>
<meta property="fb:app_id" content="[YOUR_APP_ID]" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Sample article" />
<meta property="og:image" content="" />
<meta property="og:description" content="Sample object Publishing" />
<meta property="og:url" content="">

<script type="text/javascript">
function postPublish()
{ article: '' },
function(response) {
var msg = 'Error occured';
if (!response || response.error) {
if (response.error) {
msg += "\n\nType: "+response.error.type+"\n\nMessage: "+response.error.message;
} else {
alert('Cook was successful! Action ID: ' +;
<div id="fb-root"></div>
window.fbAsyncInit = function() {
appId : '[YOUR_APP_ID]', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML

// Load the SDK Asynchronously
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); = id; js.async = true;
js.src = "//";

<h3>Sample Object</h3>
<img title="Maui"
src="" />

<input type="button" value="Publish" onclick="postPublish()" />

You can see the complete code also here from when I created the test page.

I hope this helps but feel free to ask me any questions.

As I'm having issues preserving the HTML code I have in this post since switching to "Visual" from "HTML" reformats the HTML code. I have attached the HTML code for reference when I find that it's all mangled I can revert it back.

No comments:

Post a Comment