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?
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
As instructed by this page, I include the SDK snippet into my page, except that since I don't have any Facebook APP and I was just trying to build a custom share button on my page, I leave parameter "app-id" as null. To test if it is up and running, on console I execute
FB.getLoginStatus(function(response){
console.log(response)
})
while I am logged in FB. However, it returns undefined, which means there is no response. What is wrong? Is this because I didn't assign a "app-id"?
It depends on where you're calling getLoginStatus from and in what order. It needs to be inside your fbAsyncInit function:
window.fbAsyncInit = function() {
FB.init({
appId : 'your-app-id',
xfbml : true,
version : 'v2.4'
});
FB.getLoginStatus(function(response){
console.log(response);
});
}
(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'));
That should load the SDK, initialize everything, then get your login status.
I added the facebook like button which I generated on the developer`s site, but the problem is that when when I change my url the like button counter changes:
url : http://localhost/ci/ --> 7 likes
url : http://localhost/ci/fr/--> 0 likes
sdk:
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId : 'xxx', // App ID from the App Dashboard
channelUrl : 'http://localhost/ci', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
});
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK's source Asynchronously
// Note that the debug version is being actively developed and might
// contain some type checks that are overly strict.
// Please report such bugs using the bugs tool.
(function(d, debug){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
ref.parentNode.insertBefore(js, ref);
}(document, /*debug*/ false));
like button init from https://developers.facebook.com/docs/reference/plugins/like/:
<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=xxx";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
How can i have the same counter for each page?
you have not tried HTML tag?
<div class="fb-like" data-href="http://URL_SAME" data-send="true" data-width="450" data-show-faces="true"></div>
with same url in data-href ???
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.
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