facebook login button with custom popup - facebook

i have included a facebook login button like this
<div id="fb-root"></div>
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id))
return;
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/de_DE/all.js#xfbml=1&appId=592370847463963";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-login-button" data-width="200"></div>
but i don't want the default behaviour on click.
is it possible to define my own onclick function for the button?

Well... Please consider that you cannot create custom Facebook Login Page due to security reasons.
Let's assume that this works as you wanted. It means that you can hijack FB user's name & his password within your page. Nobody will be pleased with this behavior.

Related

Facebook Share Button - 'Attachment Could Not be Found'

I have implemented the Facebook share button as follows:
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="http://www.facebook.com/bookf1" data-layout="button_count" data-share="false" data-width="180" data-show-faces="false" data-font="tahoma"></div>
<div class="fb-share-button" data-type="button"></div>
It appears on my website as expected and clicking it brings up the sharer.php with the expected display. However, when I click the 'Share Link' button it shows the 'thinking' animation for a second then nothing happens. The sharer.php pop-up just remains on-screen.
If I try and share the link via a private message I get an error saying "The Attachment Could Not Be Found".
This is running on a publicly accessible URL.
Any suggestions would be greatly appreciated as I can't seem to find this issue anywhere else.
Thanks!
I ran into a similair issue with exactly the same symptoms and wasted some time here.
After clicking my share-button the expected popup opened. In the url it was visible that sharer.php was called with an unknown (to me at least) app-id as parameter. After creating a facebook app for the website in question and putting the newly created app-id as parameter ..
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/de_DE/sdk.js#xfbml=1&appId=MY_APP_ID&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
.. it worked.
For debugguing purposes it could be helpful to put another source for js.src:
[...]
js.src = "//connect.facebook.net/de_DE/sdk/debug.js[...]
[...]
This will log debugging messages to the js-console. (As can be read up here: https://developers.facebook.com/docs/javascript/quickstart/v2.0#advancedsetup)

Facebook Sign Up Link Broken

I've set up a Facebook Like button on my site. It seems to work fine. If I like something it appears on my Timeline and all the links work.
However, if I'm logged out of Facebook and you get the message 'Sign up to see what your friends like'. Clicking sign up takes you to Facebook and tries redirecting to r.php.
The Javascript code I have in my footer is exactly what Facebook suggests:
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=487139091399600";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
Sample page is
http://www.visitkievukraine.com/accommodation/premier-palace/
Run through the debugger fine.

how to load facebook activity feed in website only when called or facebook is selected

I have successfully added facebook activity feed in my site.But now I have a dropdown with functions as facebook, twitter, rss feed and so on.So only when I click facebook from the dropdown activity feed should be loaded in that specific portion.How am I do that.I have included the following.
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
I tried to append as follows.
parents.append('<div class="fb-activity fb_iframe_widget" data-header="true" data-height="300" data-width="300" data-action="like,comment,recommend,share,suggest" data-site="http://www.icimod.org/" data-app-id="118280394918580" fb-xfbml-state="rendered">');
but it only shows the above div and no feeds.
Any suggestions/advice are welcome.Thanks in advance.
User $.getScript() to dynamically load the script once facebook option is loaded.
$.getScript(url)
.done(function(){
parents.find('div.item').append('<div class="description disp hover"><div class="fb-activity fb_iframe_widget" data-header="true" data-height="300" data-width="300" data-action="like,comment,recommend,share,suggest" data-site="http://www.icimod.org/" data-app-id="118280394918580"></div></div>');
});
get to know about $.getScript().

My facebook like button is not showing up

I looked at previous asked questions about the facebook like button and didnt see anything that was wrong with my code. Here is what I have:
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);}
(document, 'script', 'facebook-jssdk'));</script>
</body>
After adding the code for initializing the Facebook's Javascript SDK you also have to add the code to display the Like button at the required place. The generic code for it is
<div class="fb-like" data-send="true" data-width="450" data-show-faces="true">
</div>
If you want you can further customize it by checking documentation here.
Had the same problem, once I published the page, the like buttons showed up
facebook page : settings : Page Visibility : Page published
(the page was "unpublished" by default even after I did publish it for the first time)
I know topic is old but still coming up in searches.
Here's the initialization code I used:
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
Important:
By default Facebook auto-configuration tool (https://developers.facebook.com/docs/plugins/follow-button) does not prepend "HTTPS" when exporting the js.src element.
If testing this on localhost host you will run into problems with the button visibility (c.f. v2.9) Either use a https tunnel service such as ngrok or deploy to valid https server.
Adding version to the url js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.11"; helped in my case.

Facebook share and comment boxes don't work together

I want to include Facebook share button and comment box to my website.
I have a code for share button:
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"
type="text/javascript">
</script>
<a name="fb_share" type="icon" share_url="www.example.com"></a>
For comment box:
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=258471354227171";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-href="www.example.com" data-num-posts="3" data-width="600"></div>
Separately it works perfect, but when i put it in one page just one of them is working. What is a problem?
I think the solution you need is here:
Facebook Like button sometimes appears sometimes not
Basically you need to add the FB.share script after all.js.