get number of comments of facebook comments plugin - php

I have view.php and index.php.
I implemented fb comment plugin in view.php and I want to display number of comments on index.php
This is how I am displaying comment box dynamically in view.php
<div class="fb-comments"colorscheme="light"
data-href="http://www.example.com/'.$product["id"].'"
data-width="100%" data-numposts="5"></div>
This is what I have in header of view.php
<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/sdk.js#xfbml=1&version=v2.4";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
How can I display number of comments on index.php?

The Comments Count plugin will help you out!
Follow the docs, and you'll have a comment count after each post. Remember to include the Facebook code you've got in the view.php header on index.php too!

Related

Login With Facebook Button do not work

Currently, I am using this code for login with Facebook link:
<?php Login With Facebook ?>
It works perfectly fine. But I am trying to use official login with facebook button
I placed this code, at the starting of body tag:
<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/sdk.js#xfbml=1&version=v2.9&appId=15885xxxxx491691";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
And using this where i want the button to appear:
<div class="fb-login-button" data-max-rows="1" data-size="medium" data-button-type="login_with" data-show-faces="false" data-auto-logout-link="false" data-use-continue-as="false"></div>
But when i click on the button, It pop-up a new window (to facebook), and then close itself within 1 sec. That's all.
Do i need to change the URL in Javascript or something?
I tried to change the URL in java script like this:
<?php echo'js.src = "'; echo htmlspecialchars($loginURL); echo '";'; ?>
But then even the login button do not show up

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>

Facebook like button with auto URL - Joomla K2

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/

how to get javascript code as a responce and set in div from ajax page?

I want to get Facebook comments box, which I am getting from AJAX page in response. But when the data is coming from ajax, I am alerting it. It is showing in alert box, but when I am trying to set it in my div, it's not setting properly.
Here is my piece of code in which I want to set in div to get from the AJAX page.
<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-comments" data-href="https://www.facebook.com/video/embed?video_id=23423424242" data-width="470"></div>
Why is it not setting in the div?
Assign ajax response to div like this
$('#your_div').html(response);

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