Embedding a facebook like button on a facebook fanpage tab - facebook

I've been trying to find out how on earth to add some kind like button on a facebook fan page. I know there are ways of doing this. This page for instance has implemented one kind of like button: http://www.facebook.com/JimBeam?v=app_100742133310820
I know both of these pages use applications and not the static FBML page that you usually use. So I created an application where it works beautifully.
On this application, the like button works. However when I try to add it to a tab on a facebook page I get an error saying: "HTML error while rendering tag "iframe": iframes forbidden by flavor TabFBM" So apparently iframes aren't allowed to render. But obviously there are ways around this so do you have any clue on how they did it on the other pages?
I'd really appreciate an answer, and I'm especially curious whether if someone could figure out how they restyled the like button on Jim Beam's page.

Facebook page's tab are FBML. And you can not directly add the like button (fb:like or anything else) on this page. But there is a "trick" to do this, and page you give implement the following:
The only way to get the like button is to load it in an iframe. But iframes are forbidden in page's FBML as well. So the trick is to load an html page with AJAX (fbjs calls) which contains an iframe with the fb:like button. As Facebook forbids javascript autofiring, you need a like or a picture to get clicked on before doing the ajax call to load your html's iframe. This mostly is a pain in the ass.
So, here is the proof of concept code.
First file: index.html:
<script type="text/javascript">
<!-- function launch_code() {
var ajax = new Ajax();
ajax.responseType = Ajax.FBML;
ajax.requireLogin = false;
ajax.ondone = function(data) {
document.getElementById('content').setInnerFBML(data);
}
document.getElementById('content').setTextValue('Loading, please wait.');
ajax.post('http://example.com/greatpageapp/iframe.html');
return false; }
//--> </script>
<div id='content'>
<input type='button' onclick='launch_code(); return false;' value='click on me' />
</div>
And the iframe.html contents:
<center>
<table valign="top" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" width="520" height="1500">
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgoogle.com%2F&layout=standard&show_faces=true&width=450&action=like&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
</td>
</tr>
</center>
Tested now and working. Hope that helps.

Related

Hide Scrollbar from Facebook iframe

The question has been asked prior but no clear response was obtained
I an using Facebook's plugin which lets one embed and promote any public Facebook Page on a website
I am trying to hide not remove the scroll bar from the side
I still want scroll functionality but I do not want the scrollbar to be visible
What is the best method to achieve this functionality
https://jsfiddle.net/wesuf2tq/1/
<md-card style="width:auto">
<md-card-header style="background-color: dodgerblue; font-size:15px;font-weight:600; color: white; ">
<i class="fa fa-facebook-square" aria-hidden="true" style="font-size:40px; margin:0 auto"></i>
</md-card-header>
<div class="facebookContainer" >
<iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2FKobe%2F&tabs=timeline&width=340&height=500&small_header=false&adapt_container_width=true&hide_cover=false&show_facepile=true&appId"
height="800" style="width:100%;border:none;overflow:hidden;"
scrolling="no" frameborder="0" allowTransparency="true"
allow="encrypted-media"></iframe>
</div>
</md-card>
There is absolutely no way to achieve this at all - the plugin loads its content into the iframe from a different origin, so the Same Origin Policy prevents you from accessing anything inside it via JavaScript, or to inject any custom styling.
You are limited to the configuration options Facebook offers here - and hiding the scrollbar is not one of them.

Facebook likebox and Twitter feed are blank on second view in Meteor app

I have put a Facebook likebox and a Twitter feed into my Meteor app's homepage. The first time you navigate there, it works fine. But if you leave the page (while staying on the site), and then return, they are blank. This happens on multiple browsers and on Mac and PC.
I am using Iron Router, and Twitter template code like this:
<template name="twitter_feed">
<div class="news-box">
<a class="twitter-timeline" href="..." data-widget-id="..."></a>
</div>
</template>
with javascript:
Template.twitter_feed.rendered = function () {
!function(d,s,id){
var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';
if(!d.getElementById(id)){
js=d.createElement(s);js.id=id;
js.src=p+"://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);
}
}(document,"script","twitter-wjs");
}
(It's the same if I put the javascript into the template directly using <script>.)
How can I fix this? Here's the site if it helps: Signup Zone.
Thanks!
This is a problem for site that loads content in AJAX.
You need to manually force those widgets to re-parse the page. One workaround could be using jQuery to regenerate the Facebook likebox and Twitter feed each time content changes. Another hack would be setTimeout as follow:
Template.home.rendered = function() {
setTimeout(function() {
twttr.widgets.load(this.firstNode);;
FB.XFBML.parse(this.firstNode);
}, 0);
}
Reference:
https://twittercommunity.com/t/cannot-update-tweet-button-with-ajax/16989
https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse/
Here's a solution that doesn't need any scripting.
Use the iframe version of the Facebook likebox code.
For Twitter, there is no iframe version. But we can make one by putting its anchor <a> tag in its own html document, and then including an iframe to that.
Eg. for my Meteor app, I have put this twitter.html into public:
<html>
<head>
<meta charset="utf-8">
<title>Twitter timeline</title>
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<a class="twitter-timeline" href="..." data-widget-id="..."></a>
<script>
!function(d,s,id){
var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';
if(!d.getElementById(id)){
js=d.createElement(s);js.id=id;
js.src=p+"://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);
}
}(document,"script","twitter-wjs");
</script>
</body>
</html>
And I have replaced the twitter_feed template with this:
<template name="twitter_feed">
<div class="news-box">
<iframe src="/twitter.html" scrolling="no" frameborder="0"
style="border: none; overflow:hidden; width:404px; height:650px; float:right"
allowTransparency="true"></iframe>
</div>
</template>
And now it shows fine on second and subsequent views.

Some social buttons sometimes not shown

I'm adding social buttons for every post link in a web site where some post links are shown at once.
The problem is that sometimes some buttons are not shown and keep waiting for a response. I've tried with some browsers and computers and it's happening sometimes with any of them.
I'm adding the buttons like this:
<div class="social">
<div class="twitter">
Twittear
</div>&nbsp
<div class="facebook"><iframe src="http://www.facebook.com/plugins/like.php?href=<?php the_permalink() ?>&layout=box_count&action=like&colorscheme=light&locale=es_ES" scrolling="no" frameborder="0" style="height:62px; width:74px" allowtransparency="true"></iframe></div>
<g:plusone size="tall" href="<?php the_permalink() ?>"></g:plusone>
</div>
This is the web page: http://nosabesnada.com/ultimas-noticias/
Any idea of why it is sometimes happening and how to solve it?

disable buy button html5 player

I have a horror music website and have embedded some HTML5 players into it at www.horror-music.co.uk
I am trying to remove the buy button from the players and I am struggling in finding where to fit the buying=false parameter in my code
My original code is as follows without any adjustments, I was wondering if you would be kind enough to tell me where to insert the piece of code above into my code below so that the buy button does not display:
<iframe
width="100%"
height="166"
scrolling="no"
frameborder="no"
src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/128832115&color=4d1188&auto_play=false&show_artwork=false">
</iframe>
<iframe
width="100%"
height="166"
scrolling="no"
frameborder="no"
src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/128832115&color=4d1188&auto_play=false&show_artwork=false&buying=false">
</iframe>
seems to work for me. So just add &buying=false at the end of the URL.

Add iframe to facebook fan page without onClick method

Is there a way to add an iframe to a facebook page without having to do the onClick functionality?
Right now I am using this code and it works fine except you have to click the link to make it show the iframe?
<!-- Start iframe CODE -->
Like me to show the iFrame link!
<fb:visible-to-connection>
<a onClick="outside_location.setInnerFBML(link_1);" style="cursor: pointer;">Click here to show the iFrame!</a>
</fb:visible-to-connection>
<div id="outside_location"></div>
<fb:js-string var="link_1">
<fb:iframe height="500" allowTransparency="true" frameborder="0" scrolling="no" style="width:100%; height: 1400px; border:none" src="http://apps.ignitesocialmedia.com/php/facebook/sandbox/tabs/iframe.php"></fb:iframe>
</fb:js-string>
<script type="text/javascript" charset="utf-8">
var outside_location = document.getElementById('outside_location');
</script>
<!-- End iframe CODE -->
It seems as though this has been done in a couple places but I cannot figure it out.
http://forum.developers.facebook.net/viewtopic.php?pid=262170#p262170