Adding "via MyApp" text to Facebook Social Plugins - facebook

With Facebook API I can create a simple "Post to my Wall" app, which adds a "via MyApp" text to every post that is published by user.
However, if a user adds a comment using Comments Box their post will show on their Wall without the "via MyApp" text. The same situation takes place when a user clicks on the Like Button and leaves a comment to their like.
What can be done to include the "via MyApp" text?
My 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/en_US/all.js#xfbml=1&appId=MYAPPID";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<fb:comments href="http://example.com" num_posts="2" width="470"></fb:comments>

In your comment box script like the one below just replace appId=3453534536334 with your application ID of MyApp
<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=3453534536334";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

Related

How to implements facebook comments plugin?

how to implements facebook comments plugin in our website?
i'm following this code for showing the comments, but why the comments plugin still not showing?
inside tag body, i'm put this 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/id_ID/sdk.js#xfbml=1&appId=<client-id>&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
and in my page, i'm put this code :
<div class="fb-comments" data-href="http://developers.facebook.com/docs/plugins/comments/" data-numposts="5" data-colorscheme="light"></div>
why still not showing?

Facebook comment box for each articles

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>

Why is the facebook script include overcomplicated?

The documentation for the Facebook like button suggests including the following script:
<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>
As I read it, this does nothing more than add the external all.js file before the first script tag on the page.
<script id="facebook-jssdk" src="//connect.facebook.net/nl_NL/all.js#xfbml=1"></script>
Is there any reason to not just add the completed script tag to the page source in the first place?
From the Javascript SDK page;
This code loads the SDK asynchronously so it does not block loading other elements of your page.
In other words, yes, you could most likely include it right away, but the user would experience it as if your page were loading more slowly.
What is the difference between this:
<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>
and this:
<script src="//connect.facebook.net/nl_NL/all.js#xfbml=1" async></script>
?

Facebook comment plugin code

I've seen some post up already around the same subject but not really what I wanted to know
But i'm trying to add the facebook comment box plug in, into my site but it doesn't seem to be working, this is the code it has given me
<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=***************";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-href="http://www.facebook.com/pages/Cuba-Street/86653690342?fref=ts" data-num-posts="2" data-width="470"></div>
But it just doesn't seem to return anything?
I checked your code without single modification, it works for me

facebook Comments Box plugin

I want use the comments box on my site to comment posts. I paste the code generated in my 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/it_IT/all.js#xfbml=1&appId=IDAPP";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-comments" data-href="https://facebook.3rdplace.com/zend/ibs_post.php?id=<?=$id_post?>" data-num-posts="2" data-width="470"></div>
If I post a comment, it appears, but it's not saved on Graph.
Where's the problem??
Ensure your data-href URL is accessable externally. Apart from that you could try and debug it using the comment.create event.
Like this:
FB.Event.subscribe('comment.create', function(comment) {
console.log(comment); // looking for comment.commentID - https://graph.facebook.com/<comment_id>
});