Facebook like button with auto URL - Joomla K2 - php

I am developing a website which has a Blog, with multiple articles and URLs.
I need to insert Facebook Like Button with auto-detect URL. Is that possible?
Tried this CODE, but shows an error in frontend.
<div class="itemFacebookButton">
<div id="fb-root"></div>
<script type="text/javascript">
(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>
<div class="fb-like" data-href="<?php echo $this->item->link; ?>" data-width="450" data-layout="button_count" data-show-faces="false" data-send="true"></div>
</div>

Facebook has a tool for this or am I missing part of the question?
https://developers.facebook.com/docs/reference/plugins/like/

Related

How to Share my URL to the social media?

I have created URL something like: http://example.com/namespace/page#img-3
I want to share my URL same as given above. But, when I share this URL to the social media it is sharing only page URL: http://example.com/namespace/page
without #img-3
#img-3 is the element id which I want to share from the page and pass it into the anchor tag to add in the URL
<a href="#img-<?php echo $video->getId(); ?>">
<img src="https://img.youtube.com/vi/<?php echo $video->getVideoUrl() ?>/0.jpg"/>
</a>
I am using below FB share code:
<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 = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.11&appId=1336483029802737';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-href="<?php echo $baseURL_l.'video#img-'.$video->getId()?>" data-layout="button_count" data-action="like" data-size="small" data-show-faces="true" data-share="true"></div>

Comment plugin in PHP Facebook API

I am using the facebook comments plugin in one of my portals, but it does not work exactly as I want.
I have installed a faceboom app inside my facebook profile. When a user loged with facebook in the comments API makes a comment this comments is made by my app profile in his/her facebook wall or profile.
I would expect the comment will be in my own profile made by the user that has performed the comment. It is possible to do it in that way?
Here is some code:
<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/<?php echo $fbLang; ?>/all.js#xfbml=1&appId=XXXXXXXXXXXXXX";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<div class="fb-like" data-href="<?php echo 'http://www.mydomain.com.com/index.php/es/?option=com_content&view=article&id=' . $id ?>" data-send="true" data-layout="button_count" data-show-faces="true" data-action="recommend" data-mobile="true"></div>

Recommend Button Doesn't show in Firefox

I am using the Facebook Recommend button on my site and it doesn't appear to show up in FireFox browsers. It works in IE, Chrome, Safari, just not FireFox... I have it being shown next to a twitter button which shows up properly in all browsers. Any idea what could be happening?
Javascript:
<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&appId=324704914260494";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
Where it should display:
Tweet
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<div class="fb-like" data-href="http://www.example.com/index/billdets.php?billnum=<?php echo $billnum?>" data-send="true" data-layout="button_count" data-width="200" data-show-faces="true" data-action="recommend"></div>
Like I said it works in every browser but Fire Fox... any idea? I tried turning on Fire Bug and I get this:
document.defaultView.getComputedStyle(a, null) is null
http://connect.facebook.net/en_US/all.js
Line 67
I have a feeling it could be that I am using Jquery and wowwindow to open this page in a pop-up window but not sure why it is only breaking in one browser.

Social Media Buttons in PHP, HTML: Taking too much time to load and distorting page

I've added social media buttons on my sidebar using PHP and HTML syntax. However everytime I refresh the page, it takes 4-5 secs to load and during the last second it distorts all the context of the page, then it becomes normal and looks exactly the way I want it.
Is there a way to remove this time-lag and distortion of page?
Here is the code:
<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> <script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
And I've put this part of the code inside the body.
<div> <g:plusone></g:plusone> </div></br>
Tweet
<div class="fb-like" data-href="http://ph.one.un.org/omt" data-send="true" data-layout="button_count" data-width="800" data-show-faces="true" data-font="arial"></div></br></br></br>
Try and make it so you only have one request. I generally use AddThis for that kind of thing. It's pretty nifty.

Facebook like button solution

Well, I found this Facebook like button code from Facebook Developers page and i add this to www.favoritebd.com. It's working but DIDN'T COUNT THE NUMBER OF LIKE !
<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>
<div class="fb-like" data-href="http://www.favoritebd.com" data-send="false"
data-width="450" data-show-faces="true"></div>
Any idea or solution, I need if anyone like this then count will be shown..
Everythings okay I just clicked the button and it returned "2 People Like This"

Categories