Add Facebook Videos to Fan Pages Using FBML

March 9, 2010 7 Comments

Wouldn’t it be cool if you could add a video right to one of your tabs on your Facebook fan page? Now you can!

First, just set up a tab with the FBML application. The following FBML snippet will help you get started. I’ve marked in the areas that need special attention. See below for how to swap them out and where to get each item.

<fb:swf swfsrc="{__SWF_source.swf__}?v={__videoid__}&ev=0" flashvars="video_autoplay=1&video_src={__url.mp4__}&fbt_play_again=Play+Again" imgsrc="{__thumb_URL__}" width="{__width_in_px__}" height="{__height_in_px__}" imgstyle="width:{__width__}px; height: {__height__}px;" />

Each of the sections marked in {__} needs to be replaced. To get the values you need, you need to go to the video tab in your page and find the video you’re trying to add. You can click View Source and dig through the code, but the easiest way to do this by far is to use Firefox with FireBug. Firebug is a plugin that will allow you to quickly see the HTML associated with an element on the page. Once installed, navigate to the page with your video on it and click on the little bug in the bottom right corner of the browser. The firebug panel will appear at the bottom of the screen. Click on the small blue arrow and you’ll be able to mouse-over elements on the page and see the corresponding HTML code below. Each of the elements below are easily found by using firebug to get the block of code for the video on that page.

Firebug in action:

Sample HTML code from a Facebook video:

<embed width="756" height="540" flashvars="video_id=1189859419627&amp;video_length=348680&amp;video_seconds=348&amp;video_category=0&amp;video_rotation=0&amp;fbt_play_again=Play+Again&amp;fbt_go_to_video=Go+to+Video&amp;fbt_next_video=Next+Video&amp;fbt_share=Share&amp;play_context=6&amp;connect_to_owner=0&amp;share_id=s%3D11%26appid%3D2392950137%26p%5B%5D%3D1189859419627&amp;video_player_type=video_player_hq_permalink&amp;lowqual_width=400&amp;lowqual_height=300&amp;highqual_width=716&amp;highqual_height=540&amp;lowqual_stage_width=500&amp;lowqual_stage_height=300&amp;highqual_stage_width=756&amp;highqual_stage_height=540&amp;video_width=716&amp;video_height=540&amp;mvp_connect=1&amp;stage_width=756&amp;stage_height=540&amp;video_owner_name=Twin+Harbor+Web+Solutions%2C+Inc&amp;video_owner_href=http%3A%2F%2Fwww.facebook.com%2Ftwinharbor&amp;video_src=http%3A%2F%2Fvideo.ak.facebook.com%2Fvideo-ak-sf2p%2Fv2686%2F179%2F52%2F1189859419627_4540.mp4&amp;video_timestamp=Added+about+7+months+ago&amp;video_title=Waypoint+Site+Traffic+Statistics+%5BHQ%5D&amp;thumb_url=http%3A%2F%2Fvthumb.ak.fbcdn.net%2Fvthumb-ak-sf2p%2Fv2336%2F126%2F107%2F1022602683%2Fb1022602683_1189859419627_1403.jpg&amp;highqual_src=http%3A%2F%2Fvideo.ak.facebook.com%2Fvideo-ak-sf2p%2Fv6808%2F179%2F52%2F1189859419627_43357.mp4&amp;lowqual_src=http%3A%2F%2Fvideo.ak.facebook.com%2Fvideo-ak-sf2p%2Fv2686%2F179%2F52%2F1189859419627_4540.mp4&amp;fbt_lowqual=View+in+Regular+Quality&amp;fbt_highqual=View+in+High+Quality&amp;highqual_is_on=1&amp;motion_log=%2Fvideo%2Fmotion_log.php&amp;histogram_is_on=1&amp;video_autoplay=0&amp;width=756&amp;height=540&amp;user=1022602683&amp;log=no&amp;div_id=id_4b96b2d08bb3b1bffb4f1&amp;swf_id=swf_id_4b96b2d08bb3b1bffb4f1&amp;browser=Mozilla%2FNetscape+6.x&amp;string_table=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fflash_strings.php%2Ft88067%2Fen_US" wmode="opaque" scale="noscale" salign="tl" allowscriptaccess="always" allowfullscreen="true" quality="high" bgcolor="#000000" name="swf_id_4b96b2d08bb3b1bffb4f1" id="swf_id_4b96b2d08bb3b1bffb4f1" style="" src="http://static.ak.fbcdn.net/rsrc.php/z4HBM/hash/3krgnmig.swf" type="application/x-shockwave-flash">

SWF Source

This is the source of the SWF file (flash file) that acts as the player. Look for the URL that ends in .swf (highlighted in red above).

MP4 Source

This is the only somewhat tricky part. You need to specify the source video file, an MP4 file. It’s in there, but a little harder to see. I’ve highlighted the part you want in green this time. It looks like this:
http%3A%2F%2Fwww.facebook.com%2Ftwinharbor&amp;video_src=http%3A%2F%2Fvideo.ak.facebook.com%2Fvideo-ak-sf2p%2Fv2686%2F179%2F52%2F1189859419627_4540.mp4

Why does this look so weird? It’s encoded. Encoding essentially means, you can take one URL, and pass it as a parameter inside of another URL, but you have to encode the special characters. Take this URL and decode it back to normal by using an online URL decoder, found here. Paste it in, hit decode, and you’ve got your URL.

Video ID

This is the long number also highlighted in red above. This will tell the player which video to load.

Width and Height

The width and height of the video are customizable. The originals are specified in orange above. You can choose to display the video in a smaller space if you like. You need to specify them manually, both the width and the height. You also need to specify them twice; once in a style tag, once in attributes right on the main tag. Doing it twice helps browser compatibility. Internet explorer doesn’t respect the element attributes, so you need to add the style tag to make sure it works everywhere.

You should also be aware of proportions. Sometimes you need to do a little algebra to get the video to the correct size. The formula is simply, W1/H1 = W2/H2. I suppose a separate post is in order for that bit.

Thumb URL

You’ll want to specify a thumbnail URL. This is the image that displays before you click and play the movie.

Other Notes

* News, Uncategorized
7 Comments to “Add Facebook Videos to Fan Pages Using FBML”
  1. Arik says:

    a free tool that does everything explained here automaticly!
    only paste the “HTML code from a Facebook video” choose width,height and thmbnail, and get the output ready for fbml!!!
    http://www.facebook-fbml.com/fbml-facebook-video-embed-tool

  2. Lindsay says:

    This a really good URL encoder: http://quick-encoder.com/url

  3. Will says:

    Hi there – great help – thank you, but can’t seem to get my code to work. You can view page at http://www.facebook.com/pages/The-Global-Party-Inspired-by-Phileas-Fogg/135739183144499?v=app_4949752878#!/pages/The-Global-Party-Inspired-by-Phileas-Fogg/135739183144499?v=app_6009294086

    Code used is:

    If you could help me at all I would really appreictae it!

    thank you in advance,

    Will

  4. Camila says:

    hello, i was trying to put the code and when i got it all right it appeared in the fbml tab, but when i clicked to watch it said that the video was no longer available, but it is because when i look at it normally from the video app it still there, what do u think went wrong?

  5. Hoidlimb says:

    Hey guys, – for several of you who gamble a couple dimes to win thousands: this is a good web site that processes Canadian players and gives away 100% refund casino bonus and 20$ free casino bonus to each new player. They also offer blackjack, video poker, slot machines, roulette & other 300+ internet casino games playable.
    Last Tuesday I cashed almost 1K there, and the withdrawal was smooth and quick. Highly advised:
    online casino free

Leave a Reply

(required)

(required)


How to import contacts from a CSV file in Outlook 2003

In outlook 2003, go to File >> Import and Export… Select ‘Import from another program or file’ Select Comma...

Are you backing up your data?

Most people know they should back up their data, but not everyone does. If you’re one of those people,...

5 Easy Choices For a Better Website.

Are you planning to design or redesign your website soon? If so, then here are a few tips that...

How to enable site maps in Waypoint

Sitemaps are simple XML files that Google and other search engines use to find the content in your website....

5 reasons you should learn how to use HTML

HTML is the backbone of everything online. Everyone should know how to read it and write it! OK, well...

How to Link Facebook to Twitter

Posting to Facebook, LinkedIn, Twitter and other social media sites is a great way to interact with your customers....

Visual Studio Environment Tips

This week I had to send my iMac in for repair. Normally I program using Windows Server 2008 running...

Fixing IIS7 Maximum Upload Size

If you have your Waypoint site hosted with Twin Harbor and you need to increase the maximum file upload...

What is an SSL Certificate?

You may have heard about SSL Certificates, also called secure certificates, or SSL Certs for short. But what are...

OSX Lion Removes Functionality

In my previous post I thought I had found a way to maintain some of the functionality that we...