-
Get Email Updates:
-
Recent Posts
-
Recent Comments
-
Archives
Categories
- Blogging (1)
- CMS (2)
- Facebook (1)
- hosting (1)
- HTML5 (1)
- Javascript (1)
- Microsoft (1)
- microsoft project (1)
- Website Design (6)
- Wordpress (3)
Tags
blog management blog writer blog writing cloud hosting cms content management systems copywriting facebook blog integration facebook open graph facebook social plugins facebook wordpress integration Flash free icon hosting HTML5 icon sets microsoft project minimal design open graph walkthrough social media management successful website web icons web pages website design wordpress wordpress blog wordpress development wordpress integration wordpress match website wordpress video tutorial wordpress website design
As Facebook becomes an ever increasing influence on the internet and it’s users, webmasters all around the world in every market are trying to find ways to better connect with Facebook users on their sites. Facebook has come a long way in a short time, and is now at a point where a very deep integration with Facebook is available to webmasters through the Facebook Open Graph Protocol. With a full Facebook integration you will enhance your Facebook marketing effectiveness.
We are going to take you step by step through a full integration of Facebook into your WordPress blog or website. We will focus on using the social plugins which utilize XFBML markup and Javascript SDK. Using a full Facebook Open Graph Protocol integration with your site will allow you do such things as:
Add a like button. The like button will allow users to add comments and a picture to their wall feed when they like content from your site. With a full Like button integration your content becomes it’s own “Page” on Facebook that can be accessed along with the other Pages you are an administrator on. You get full access to the Page’s analytics data and sharing capabilities. You will be able to share updates to users that have liked your content as well as target ads at them. This is much better than using the old crappy Iframe like button!
Activity Feed. The activity feed allows a webmaster to show personalized content about the user and or their friends when they are logged into Facebook and visiting your site. If they are not logged in, you will be able to show recommendations from your site. This is a handy plugin to get users engaged in your site with little effort on your part.
Recommendations. This plugin allows you to share recommended content with visitors from any site you wish whether they are logged in or not. It shows interactions the user’s friends have had with your site to help them find what they may be interested in as well.
The Like Box. This box allows visitors to become a fan of your Facebook Page with one click from your site or blog. It showcases fans and content from your Facebook Page to entice your visitors to become a fan. The like box is the quickest way to grow your Facebook Page following with the least amount of effort. If you are offering quality content on your main site, you are greatly increasing the chances of gaining more followers on your fan page with a Like Box implementation.
Login Button. The Facebook login button will allow your visitors to see any of their friends that have already signed up for your site using the Facebook login button. Your visitors will be able to login as well. One thing that prevents people from registering on sites is that it’s too time consuming Confirmation emails and spam prevention make it too tedious to sign up, but a Facebook login integration will solve those problems for your users.
Registration. The Facebook registration will allow visitors to register for your site using their Facebook profile. If they are logged in already the form will be pre-filled out with their information for them. Using the API you will be able to gather information outside of the normal Facebook fields.
Facepile. This one is purely for showing off. You can display the faces of Facebook users that have registered or liked your page. Show off your social skills with a Facepile of Facebook users! Yes the name is corny and it doesn’t have much functional usage for your site, but in some cases it may give you more credibility and trust to show that a users friends are already liking your site.
Comments. Allow logged in Facebook users to comment on your site using the Facebook comments. They will also be like-able and shareable on Facebook walls and feeds. I do like that Facebook comments make it easy for users to participate in a conversation, but the downfall is that comments are not indexable at this time, so from an SEO perspective it has little value.
Live Stream. This plugin will allow Facebook visitors to communicate in real time by sharing activities and comments. If your running a real time event, Live Stream may be just what your looking for to keep your visitors connected.
Ok, now that you have an idea of what you can do using a true Facebook integration on your site, lets get down to the nitty gritty.
Creating Your Facebook App
The first thing your going to need to do is head on over to the Facebook Developers page where you will need to setup your very own Facebook App. From this page you will be able to see all of your existing Facebook Apps on the right side of the page. On the upper right hand side of the page you will want to click on the “Setup New App” button.
On the next page you will need to enter your App name and agree to the terms and conditions.
Moving right along you will find yourself able to edit all of the details about your new App. While much of the information here is not required, you can feel free to fill it out in as much details as you may like. You will find six menu items on the left side consisting of: About, Website, Facebook Integration, Mobile and Devices, and Credit.
Click on the website tab where you will see your Facebook Application ID and Secret code. You will be needing these for your Facebook Open Graph Protocol integration, so make a note of them! You can always get them at any time in the future by returning to the Facebook Developer’s Page and viewing or editing your existing Facebook Apps.
Make sure you enter the full website URL on the “site URL” field. For example http://www.mysite.com. The field below is asking for the “site domain”. This is the actual domain such as mysite.com. It will allow Facebook to authorize authentication on this domain and all subdomains, so do it!
This is really all that is required to get us going, so we won’t go into much more detail. Feel free to scan through all the advanced options you can set for your App. Also feel free to upload logos and avatars for your new App. Again, none of that is required, but it won’t hurt you to do so.
Implementing the Open Graph Protocol On Your Website Or Blog
It’s time to get down to some dirty work. You will be editing the code of your site, so make sure you have a backup you can fall back on just in case you make any mistakes. For the purposes of serving the masses, we will use WordPress as the platform we are integrating Facebook into. Remember that this will work for any website integration, it’s not just for WordPress.
Lets start by declaring the Facebook document types in your header. Right below the document type declaration you will want to insert the following code:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml">
Now we need to add all the meta information that will inform Facebook about the content of your page. It’s important to include as much of this information as possible, so don’t skip any Open Graph Protocol meta tags if you can help it. Paste the following code before the closing </head> tag. I like to make them the first bit of code after the opening head tag myself:
<meta property="og:title" content="<?php the_title() ?>"/>
<meta property="og:fb:app_id" content="1111111111"/>
<meta property="og:type" content="movie"/>
<meta property="og:url" content="<?php the_permalink() ?>"/>
<meta property="og:image" content="<?php echo catch_that_image() ?>"/>
<meta property="og:site_name" content="<?php bloginfo('name') ?>"/>
<meta property="fb:admins" content="USER_ID"/>
<meta property="og:description"
content="A group of U.S. Marines, under command of
a renegade general, take over Alcatraz and
threaten San Francisco Bay with biological
weapons."/>
<?php function og_meta_desc() {
global $post;
$meta = strip_tags($post->post_content);
$meta = str_replace(array("\n", "\r", "\t"), ' ', $meta);
$meta = substr($meta, 0, 200);
echo "<meta property=\"og:description\" content=\"$meta\"/>";
}
og_meta_desc();
?>
Now you’ll need to paste the following code into your functions.php file. This is required so that it will automatically populate the first image of your post as the one to be used when someone shares your content with a like. as you can see, you can also define a default image if you wish just in case there is not one on the post:
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = "/images/default.jpg";
}
return $first_img;
}
Now lets take a brief look at what we’ve done here. We’ve given you all the dynamic calls you will need to pre-populate all the Facebook Open Graph Protocol meta tags with data from each new post you make on your blog! There is no maintenance required at this point.
- og:title: Title of the post. We are dynamically pulling in the WordPress post title for this tag.
- fb:app_id: insert whatever the Facebook App ID is you received earlier in the post.
- og:type: The type of content of the page. For blogs the type is typically “article”
- og:site_name: Name of the blog
- og:url: Permalink to the post. In this case we are dynamically pulling the permalink to your WordPress post and populating this meta tag with that data.
- og:image: The code above allows you to dynamically pull the first image of the post and populate this meta tag with that image. It also allows you to define a default image that can be used in the event that there is no image on the post. This saves you alot of time and headaches updating this meta tag with each new post.
- og:description: This is a description of the post. We are dynamically pulling in the description from the Post excerpt for you.
Now you will need to add the Javascript SDK code to your site so that you can being utilizing social plugins using the API. In order to add the Javascript SDK code to your site, simply paste the code below directly after the opening body tag:
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: 'your app id', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
This code is loading the Javascript Asynchronously so that it doesn’t block any other elements of the page from being loaded. We have your back
. Make sure you replace “your app ID” with your actual Facebook App ID you put in the meta tags above.
At this point you have successfully implemented the Facebook Open Graph Protocol on your site and your now ready to begin using it to enhance your blog with the aforementioned social plugins. Read our other posts to learn how to implement a Facebook Like Button or Facebook Like Box to your blog! we will be writing further walk through’s about how to enhance your blog with other Facebook integration features soon.
Link to this post!
This entry was posted in Facebook, Javascript, Wordpress and tagged facebook blog integration, facebook open graph, facebook social plugins, facebook wordpress integration, open graph walkthrough. Bookmark the permalink.




(






 

Pingback: Tweets that mention How To Implement Facebook Open Graph Protocol On your Website Or Wordpress Blog | Website Design & Development -- Topsy.com
Hi Chris,
This is the best explanation to use Open Graph in WordPress, however I would like to point out one thing. In the code that goes in header near the line <meta property="og:description" the description of the site needs to be present. As you have mentioned to copy the whole code, it will also copy the site description to the marine one that is mentioned. Instead the user need to change that part to their own site description.
Just my 2 cents
Yes good point. We will go back and revise the post shortly for people
Very good point. Users should change that info!
Thank you for your nice post!
Your post very helpful.
Glad to be of service!
Good morning.
I am trying to implement a facebook like to my company pages, its a simple html page with a little java, no PHP, will your scripts still work? What have I done wrong from Facebook's directions that makes this like not work for me?
What is supposed to happen is something comes up on a person's news feed with an image, or a box is supposed to show up. OR something. So far, nothing has happened.
URL for test page with like button.
http://www.napoleongrills.com/Gourmet-grills/Pres…
Hi there.
Andrea Again.
Okay, so I have a couple of things happening.
The button "works" but comes up with an error "The page at http://www.napoleongrills.com/Gourmet-grills/Pres… could not be reached."
The address I have given is NOT the same as the address that the error is saying it cant find.
<<CODE>>
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords"content="grills,gas grills,gas grill,gas,grills,grill,propane grills,propane,barbecue,barbeque,propane barbecue,gas barbecue,propane,barbecue,recipes,tips," />
<meta name="description" content="Napoleon Gourmet Grills, quality gas or propane grills & accessories that stand the test of time. Find grill accessories, recipes galore as well as all of your barbecue needs including spices, rubs and specials." />
<meta property="og:title" content="Prestige PRO™ PRO600RSIB Gas Grill"/>
<meta property="og:type" content="product"/>
<meta property="og:url" content="http://www.napoleongrills.com/Gourmet-grills/Prestige_Pro_gas_grill_series/PRO600RSIB_gas_grill_barbecue.html"/>
<meta property="og:image" content="http://napoleongrills.com/images/Facebook_likes/Pro600RB.jpg"/>
<meta property="og:site_name" content="Napoleon Gourmet Grills"/>
<meta property="og:description" content="Superior technology, rock solid performance, balanced design and unparalleled customer service are the hallmark of the Napoleon® name.
Your Napoleon® grill is designed to excel, offering a cooking experience as gratifying as the wonderful meals you’ll create with it."/>
<title>Prestige Pro PRO600RSIB Gas Grill Barbecue</title>
Scripty stuff that doesnt pertain to the question
</head>
<body>
Lookit me I am body content not pertaining to the question…
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http://www.napoleongrills.com/Gourmet-grills/Prestige_Pro_gas_grill_series/PRO600RSIB_gas_grill_barbecue.html" show_faces="false" width="450" font="trebuchet ms"></fb:like>
Please copy the address above within the like button to get to the page where the test like button is.
Dont' forget to add the javascript SDK code after your opening body tag and plug your own app Id into it…
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: 'your app id', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
I'd like to integrate the likebox onto my joomla website. But i dont know which file to add the code to ?
How do you get it to integrate with an existing Facebook page? Seems like it creates a new Facebook page using the og:title parameter. I would like to have it connect with my existing page. Thanks!
Everything works fine except I am unable to pull the image (Featured Image) from the post for the share/like button. What can I do to get it to recognize the featured image?
Thank you!!! You rock man.
Pingback: The Facebook Minimum Marketing Protocol | Holland-Mark Blog
I've got to say thanks man! This is the best article about this subject on the net and I mean that for real!
There's scant information about this level of integration for webmasters who are wanting to learn. All the doco out there either assumes that the reader is already knowledgeable in the coding aspects needed or imo is just rehashed facebook doco, by people who don't really know themselves.
I've been searching out the baby food on this so I can get the full effect out of this powerful platform but just ended up chewing through one useless plugin after another, they didn't give me the freedom to do what I want.
Chris, great post! Seems that the Open Graph Protocol is still a little known advanced data feature for websites. My understanding of it is basic, in that I get that the now a website can have pages that will exist as actual "objects" that can be parsed more universally by other sites that track data and that it can connect people in the "social web" that seems to be on a growing trend from Facebook.
Where's the code to and how do you, once you've added OG, how do you integrate facebook login with wordpress registration and comments forms?