FB.logout() called without an access token. all.js:54 - facebook-javascript-sdk

I load the facebook SDK like this:
(function(d){
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.js";
ref.parentNode.insertBefore(js, ref);
}(document));
So, I get this error:
FB.logout() called without an access token. all.js:54
How would I fix this? as its in the facebook SKD file?!

Try this code
(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'));
Full instruction can find here

Related

How to use Discourse comments in VueJS?

I have a website that uses Vuejs. And a forum in Discourse. I am trying to insert a javascript in the template file that will connect comments from the forum to a specific page on Vuejs site. But I get the error:
Templates should only be responsible for mapping the state to the UI.
Avoid placing tags with side-effects in your templates, such as <script>,
as they will not be parsed.
My Detail.vue code:
<div id='discourse-comments'></div>
<script type="text/javascript">
DiscourseEmbed = { discourseUrl: 'https://forum.epicseven.ru/',
discourseEmbedUrl: '{{url absolute="true"}}' };
(function() {
var d = document.createElement('script'); d.type = 'text/javascript';
d.async = true;
d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(d);
})();
</script>
I was try change text/javascript to application/javascript, but when i try render it, i receive error:
- invalid expression: missing ) after argument list in
" \n DiscourseEmbed = { discourseUrl: 'https://forum.epicseven.ru/',\n
discourseEmbedUrl: '"+_s(url absolute="true")+"' };\n\n (function() {\n
var d = document.createElement('script'); d.type =
'application/javascript'; d.async = true;\n d.src =
DiscourseEmbed.discourseUrl + 'javascripts/embed.js';\n
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(d);\n })();\n"
Raw expression: DiscourseEmbed = { discourseUrl:
'https://forum.epicseven.ru/',
discourseEmbedUrl: '{{url absolute="true"}}' };
(function() {
var d = document.createElement('script'); d.type =
'application/javascript'; d.async = true;
d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(d);
})();
How i can fix this error? Maybe try to use different part of code?

adding facebook sdk to react-starter-kit

Where or how do I add the FB sdk? I want to add share button and page box plugin.
<!-- fb stuff -->
<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.10&appId=${FB_APP_ID}";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- /fb stuff -->
Include the JavaScript SDK on your page once, ideally right after the opening <body> tag
Source: https://developers.facebook.com/docs/plugins/share-button/#configurator
In React, you can also load it in your main components componentDidMount function, for example:
componentDidMount() {
(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=1version=v2.10&appId=${FB_APP_ID}";
fjs.parentNode.insertBefore(js, fjs);
}
}(document, 'script', 'facebook-jssdk'));
}
The fb-root div will be auto-generated if it does not exist.
You may need to use FB.XFBML.parse in componentDidUpdate, make sure you understand why: https://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse/
Of course you can only use FB after the JS SDK has been loaded. Here is an example for the fbAsyncInit function: http://www.devils-heaven.com/facebook-javascript-sdk-login/

Custom search engine for Google not working

I am trying to integrate custom search engine of google but to no avail. Every time it returns 'No Result' for every data passed.
Code:
<script>
(function() {
var cx = '009439376788807650262:rd6prt0twra';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<div>
<gcse:search resultsUrl="http://amniltech.com.np/investment/" newWindow="true" queryParameterName="search">
</gcse:search>
</div>
Can anyone help me here? What am I doing wrong? I am using fuelphp.
<script>
(function() {
var cx = 'Your_Cx_iD';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//cse.google.com/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search resultsUrl="http://www.amniltech.com.np/investment/" newWindow="true" queryParameterName="search">
This will work.

Exclude FTP results from Google custom Search

I did get my code to implement google custom search which is below:
<script>
(function() {
var cx = '007573243353096205708:4ydbnopnt9s';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:search></gcse:search>
But this code and my public url shows me FTP results.
When I try to exclude ftp results like ftp://www.mysite.com/*
it excludes all results.
What should I do so that my search excludes FTP results.
I saw this link but could not understand where to put the code suggested
https://productforums.google.com/forum/#!searchin/customsearch/ftp%7Csort:relevance/customsearch/CitHAOTAgS4/W79di_lOuS8J
Any help is appreciated.

Localizing the sign-in button

hallo following this tutorial
https://developers.google.com/+/web/signin/#customizing_the_sign-in_button
when i implement the localization script to show the button in korean, german or whatever the g+ button dissapear
<script type="text/javascript">
// Specify the language code prior to loading the JavaScript API
window.___gcfg = {
lang: 'ko'
}
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js?onload=onLoadCallback';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
Maybe im doing something wrong but the code looks so easy...
thank you for your time and sorry for my english.
You're in luck, Ian Barber just wrote a blog post about localizing Google+:
http://www.riskcompletefailure.com/2013/08/google-sign-in-localisation.html
That should answer your question.
The issue in the code is that you are missing a semicolon after the global window config markup:
<script type="text/javascript">
// Specify the language code prior to loading the JavaScript API
window.___gcfg = {
lang: 'ko'
};
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/client:plusone.js?onload=onLoadCallback';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
Should work.