I am using below code to implement facebook comment box on my site pages :
<div class="fb-comments" data-href="http://example.com/test/public/story/read-searched-story?story=rRDMpYpeHA22aFm4OFahuV50iFqswqjzFzl7BJPbnyo=" data-numposts="5" data-colorscheme="light"></div>
<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.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
When i am posting comment it asks to publish on facebook and when i click on post nothing happens either on my wall or activity log. any help will be appreciated..!!
After searching a lot found that facebook crawler needs some ogtags to crawl all pages mentioned on https://developers.facebook.com/docs/reference/opengraph/object-type/website/ and you can check your URL on https://developers.facebook.com/tools/debug/.
Related
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)
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.
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().
I have created an facebook comment box,here's the question,if user's adding comment from random articles on the website,the comment will not shown as they comment from articles,but for whole site.how could I make this facebook comment for each articles?thanks in advance
In Javascript, the script remains the same for each articles. It looks 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_GB/all.js#xfbml=1&appId=YOUR_APP_ID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
As for the HTML, you'll have to update the data-href attribute depending on the page (article) where you are.
<div class="fb-comments" data-href="http://example.com/CURRENT_ARTICLE" data-width="470" data-num-posts="2"></div>
I am using facebook comments and providing the url of the page to distinguish. here is the code I am using
<?php $commenturl="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>
<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>
<fb:comments href="<?php echo $commenturl?>" num_posts="8" width="670"></fb:comments>
My url is www.domain.com/foldername/index.php?etc.
so it shows up the comment feed ok, but once someone posts a comment the url on his wall omits the foldername and directly goes to mangoestv.com/index.php?etc.
what am I supposed to do?
I had the same problem was solution was to use htaccess to rewrite url , because it seems that facebook considers domain.com/index.php?var=abc and domain.com/index.php?var=xyz the same
so you should have url like that domain.com/abc and domain.com/xyz
Edit :
info about rewriting url's
http://www.workingwith.me.uk/articles/scripting/mod_rewrite
http://corz.org/serv/tricks/htaccess2.php