i've been trying to implement the facebook comments-count feature on my website (using html and C#).
it's a dynamic page, created from the code behind like so:
tmpGuides = tmpGuides + "<img src=\"images/comments.gif\" alt=\"\" style=\"vertical-align: baseline;\" />" + "<fb:comments-count href=http://www.someexamplesite.com/article.aspx?=1909/> </fb:comments-count> ";
it always shows 0 instead of the real amount of comments.
i'm working from my local machine now, but i tried uploading the code to production and it still doesn't work. I also tried url encoding the address.
You do seem to have the right syntax. Are you sure there are definitely comments on the url you are using?
Following the documentation on facebook, under the heading "How do I access the number of comments left of my page?", you can see the code below works for "example.com":
<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>
<fb:comments-count href="http://example.com/"></fb:comments-count> awesome comments
If you can get try get it working for example.com then you know that you don't have a problem with your code and it is more likely that there are no comments on the url you are specifying.
Related
I am trying to add Facebook User Authentication, for Graphcool. For React, they have provided a snippet to initialize the SDK. However, since I am using React Native, "document" is not a variable. There is no tutorial for React Native on this. Any workarounds?
_initializeFacebookSDK() {
window.fbAsyncInit = function() {
FB.init({
appId : FACEBOOK_APP_ID,
cookie : true, // enable cookies to allow the server to access the session
version : FACEBOOK_API_VERSION // use Facebook API version 2.10
});
};
(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";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
}
User Facebook's FBSDK library for react-native and follow the installation and initialization implementations provided by them.
https://github.com/facebook/react-native-fbsdk
In the "Adding Messenger Extensions" guide posted below, window.extAsyncInit() is NOT FIRING after the Messenger Extensions JS SDK is done loading
1) domain is whitelisted
2) I am performing res.sendFile with a bare bones html file:
<!DOCTYPE html>
<html>
<body>
<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.com/en_US/messenger.Extensions.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'Messenger'));
window.extAsyncInit = function() {
// the Messenger Extensions JS SDK is done loading
alert("This alert isnt being executed in webview or chrome
mobile");
MessengerExtensions.getUserID(function success(uids) {
// User ID was successfully obtained.
var psid = uids.psid;
}, function error(err, errorMessage) {
// Error handling code
});
};
</script>
<h1>
Basic Text
</h1>
</body>
</html>'
3) I am accessing via persistent menu button with messenger_extensions parameter is set to true.
4) The weird behavior I am seeing with my iphone 6:
A. In webview, the alert never comes up
B. On mobile browser, the alert comes up in Safari but not Chrome
C. If I press "Request Desktop Site" while in Chrome mobile , the alert pops up
D. On my Mac (Sierra), the alert pops up in Safari and Chrome
https://developers.facebook.com/docs/messenger-platform/webview/extensions
I have used the Social Plugin in the past to place an HTML newsfeed on a website. I'm trying to do the same thing, but I'm not getting the feed to display. In fact, if I visit https://developers.facebook.com/docs/plugins/activity the demo is not displaying. Could this be something with my browser, or a bug in the plugin? Any guidance is much appreciated!!
I have this immediately after the body tag, and I have the html pasted in it's proper place.
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'YOUR_APP_ID', // App ID from the app dashboard
status : true, // Check Facebook Login status
xfbml : true // Look for social plugins on the page
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK asynchronously
(function(){
// If we've already installed the SDK, we're done
if (document.getElementById('facebook-jssdk')) {return;}
// Get the first script element, which we'll use to find the parent node
var firstScriptElement = document.getElementsByTagName('script')[0];
// Create a new script element and set its id
var facebookJS = document.createElement('script');
facebookJS.id = 'facebook-jssdk';
// Set the new script's source to the source of the Facebook JS SDK
facebookJS.src = '//connect.facebook.net/en_US/all.js';
// Insert the Facebook JS SDK into the DOM
firstScriptElement.parentNode.insertBefore(facebookJS, firstScriptElement);
}());
</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_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
The facebook comment plugin in my PHP site doesn't understand the URL in the href attrib and displays Warning: Link us unreachable.
I have tested with a file that doesn't use .htaccess which runs good and doesn't throw any errors or warnings, but when I put a virtual URL on href. Facebook doesn't understand the url.
This is the code of my site:
<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="10" width="700"></fb:comments>
This is information in my site:
$commenturl = http://smashlix.com/battle/Ipad-or-Windows-8
.htaccess content: RewriteRule ^battle/(.*)$ ./index.php?view=bd&title=$1
Please help me !
Your server responds with a 302 and a Location header, and an invalid one at that, because it does not contain a fully qualified URL: http://web-sniffer.net/?url=http://smashlix.com/battle/Ipad-or-Windows-8
RewriteRule ^battle/(.*)$ ./index.php?view=bd&title=$1
Why is there a ./ before the file name? Where is that .htaccess file located, and what’s the RewriteBase?
I have a project using "kotlinFrontend" to create a really nice react front end written in kotlin. How do i get access to the facebook js sdk (it is usually done withing script tags)
I have this code on my HTML template that includes the generated bundle containing
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '503127050093992',
cookie : true,
xfbml : true,
version : 'v3.2'
});
FB.AppEvents.logPageView();
};
(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'));
Inside my kotlin react code, how would i then be able to access the creatd FB obj?
Use external var FB
Type-safe way:
Get typescript definitions from facebook-js-sdk
Use ts2kt to convert it to Kotlin. Generated files might have some errors, but they are usually easy to fix.
Add these files to your project. You'll get external var FB: facebook.FacebookStatic that you can access.
Unsafe way:
Declare external var FB: dynamic