Facebook Javascript SDK Getting a blank page after After Accepting App - facebook-javascript-sdk

I keep getting an error while trying to use the Javascript SDK for a simple login flow. I must be doing something wrong, but cannot figure it out. I'm just trying to redirect a user after they accept the app.
Here is what is happening:
User clicks login button, the app dialogue appears (with correct permissions). They approve the app, then the popup hangs on a blank page with this url: https://www.facebook.com/dialog/permissions.request.
However, the app is approved, and if I click out of the dialogue and click the login button again, i am correctly redirected, and the app is installed.
Here is my code:
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="js/functions.js" type="text/javascript">
</script>
<link type="text/css" href="style/style.css" rel="stylesheet" />
<link href='http://fonts.googleapis.com/css?family=Oranienbaum' rel='stylesheet' type='text/css'>
</head>
<body>
<script>
// Additional JS functions here
window.fbAsyncInit = function() {
FB.init({
appId : 'my_app_id', // App ID
// Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// Additional init code here
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
$('.submit_button').attr("href","gameurll").removeAttr("onClick");
}
});
};
// Load the SDK Asynchronously
(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));
// Facebook Login Function
function login() {
FB.login(function(response) {
if (response.authResponse) {
// connected
window.location = "gameurl";
} else {
// cancelled
}
}, {scope:"publish_actions,email,user_relationship_details"});
}
</script>
<a class="submit_button" href="" onclick="login();" >Login</a>
</body>
</html>
Thanks in advance for your help

Related

Web component Poly fills are not working in IE 11. I have added the poly fill JS file in index.html file

I have added the Web component Polyfill.
npm install #webcomponents/webcomponentsjs
I have added them in my index.html file:
<script src="./webcomponents/custom-elements-es5-adapter.js"></script>
<script src="./webcomponents/webcomponents-bundle.js"></script>
<script src="./webcomponents/webcomponents-loader.js"></script>
<script src="./webcomponents/webcomponents-bundle.js.map"></script>
Also Script for no suppport.
<script>
if (!window.customElements){document.write('Web components not supported'); alert('hi');
console.log('No web component');
}
I get the data Web components not supported in IE 11.
I tried the same using Vanilla JS and HTMl
My Html code
<html>
<style>
<head>
<script src="https://unpkg.com/#webcomponents/webcomponentsjs#2.5.0/webcomponents-
loader.js">
<script>
if (!window.customElements){document.write('Web components not supported');
alert('hi');
console.log('No web component');
}else{
alert('Web componnets is supported');
}
</script>
</head>
<body>
**<my-shadow></my-shadow>**
<script src="C:\Users\rgo7cob\Desktop\shadow.js"></script>
<h3> Hello. It is in Red </h3>
</body>
</html>
I have loaded the script from https://unpkg.com/#webcomponents/webcomponentsjs#2.5.0/webcomponents-loader.js.
I get the error in IE 11 console at Line number 2 in Js file
const template =document.createElement('template');
**template.innerHTML=`**
<style>
h3{
color : blue;
}
</style>
<h3> This is data from the Template and it is blue</h3>
Browser is not able to identify the template object even after using webcomponents-loader.js.
My Web component element must look like this.
When you reference webcomponents-loader.js in the page, IE will actually be compatible with the template element. Your problem is that you need to add the template element to the body after you create it, and if you need to add html elements to the body, you need to wait for it to load, so you need to execute these codes in window.onload().
A simple example:
window.onload = function() {
const template = document.createElement('template');
template.innerHTML = "<h3>This is a template.</h3>";
document.body.appendChild(template);
}
function show() {
var shadowEle = document.getElementById('shadow1');
var shadow = shadowEle.attachShadow({
mode: 'open'
});
//add style
const styles = document.createElement("style");
styles.textContent = 'h3{ color:blue; }';
shadow.appendChild(styles);
//add h3 title
const title = document.createElement("h3");
var temp = document.getElementsByTagName("template")[0];
var clon = temp.content.cloneNode(true);
title.textContent = clon.childNodes[0].textContent;
shadow.appendChild(title);
}
if (!window.customElements) {
document.write('Web components not supported');
alert('hi');
console.log('No web component');
} else {
alert('Web componnets is supported');
}
<script src="https://unpkg.com/#webcomponents/webcomponentsjs#2.5.0/webcomponents-loader.js"></script>
<input type="button" name="show" id="show" value="show template" onclick="show()" />
<br />
<my-shadow id="shadow1">
</my-shadow>
Result in IE:

React Native firebase phone authentication

I am trying to build a React Native app using expo and firebase authentication. The email/password authentication is working fine but the phone number authentication is failing because of the applicationVerifier.
I have tried to use 'react-native-firebase' but that is also not working and giving error.
[Error: RecaptchaVerifier is only supported in a browser HTTP/HTTPS environment with DOM support.]
Thanks.
You need to make .html file and put this code..
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<title>Entering captcha</title>
</head>
<body>
<p style="text-align: center; font-size: 1.2em;">Please, enter captcha for continue<p/>
<button id="continue-btn" style="display:none">Continue to app</button>
<script src="https://www.gstatic.com/firebasejs/5.10.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.10.1/firebase-auth.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyCy6HyqIV5Q_A5lllIxZgePSmKq-Q8eqiw",
authDomain: "onsignledemo.firebaseapp.com",
databaseURL: "https://onsignledemo.firebaseio.com",
projectId: "onsignledemo",
storageBucket: "onsignledemo.appspot.com",
messagingSenderId: "223114260821"
};
firebase.initializeApp(config);
</script> <script>
function getToken(callback) {
var container = document.createElement('div');
container.id = 'captcha';
document.body.appendChild(container);
var captcha = new firebase.auth.RecaptchaVerifier('captcha', {
'size': 'normal',
'callback': function(token) {
callback(token);
},
'expired-callback': function() {
callback('');
}
});
captcha.render().then(function() {
captcha.verify();
});
}
function sendTokenToApp(token) {
var baseUri = decodeURIComponent(location.search.replace(/^\?appurl\=/, ''));
const finalUrl = location.href = baseUri + '/?token=' + encodeURIComponent(token);
const continueBtn = document.querySelector('#continue-btn');
console.log(finalUrl);
// continueBtn.onclick = (event)=>{
// window.open(finalUrl,'_blank')
// }
continueBtn.style.display = "block";
}
document.addEventListener('DOMContentLoaded', function() {
getToken(sendTokenToApp);
});
</script>
</body>
</html>
and put this file in to your running server and load your URL in to react- native Webview before sending confirmation code and after verify this CAPTCHA send confirmation code...

facebook javascript SDK return empty page after prompt for FB login

I have created my first Facebook app, which allow posting updates on my page. The version of my facebook App is v2.4. I then created a test web page with ASP.NET and use Facebook Javascript SDK to try posting a test update on my page. It opened a prompt for login and redirect to an empty popup page after I clicked login.
The followings are the codes I used:
<body>
<script type="text/javascript">
window.fbAsyncInit = function () {
FB.init({
appId: '[my-app-id]',
xfbml: true,
version: 'v2.4'
});
};
(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'));
function myFacebookLogin() {
FB.login(function () {
FB.api('/114690815550304/feed', 'post', { message: 'Hello, world!' });
}, { scope: 'publish_actions' });
}
</script>
<div>
<asp:Button ID="PostButton" CssClass="buttonM1 bGreen" runat="server" Text="Post To Facebook Page" OnClientClick="myFacebookLogin();" />
</div>
</body>
Would anyone tell me what's wrong with it?
My facebook App does work on Graph API 2.0 and did successfully post an update on my page through Graph API.
The testing web page I created is also a Https, and is updated into my Facebook App's site URL setting.
Thanks in advance for any help.

call parent javascript function from iframe

In node-webkit, call from iframe javascript to parent javascript doesnt work for me.
I am trying to launch a link in the iframe on the default browser as a result
I want to call a function in the parent window so as to call:
gui.Shell.openExternal("link");
Any help is appreciated. Thanks in advance.
What you want to do, is to intercept links in the internal frame.
Here we have an iframe where all links will open in the default browser, not in the Node WebKit context. I hope this helps.
Try this:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
window.gui = require('nw.gui');
handleLinks = function(event)
{
var href;
function checkLinks(element)
{
if (element.nodeName.toLowerCase() === 'a')
{
href = element.getAttribute('href');
if (href)
{
gui.Shell.openExternal(href);
// important, prevent the default event from happening!
event.preventDefault();
}
}
else if (element.parentElement)
{
checkLinks(element.parentElement);
}
}
checkLinks(event.target);
};
function isLoaded()
{
// let's see if the iframe has finished loading
var iframe = document.getElementById('myframe');
if (iframe && iframe.contentWindow && iframe.contentWindow.document &&
iframe.contentWindow.document.body &&
iframe.contentWindow.document.body.innerHTML)
{
//now deal with links
iframe.contentWindow.document.body.addEventListener('click', handleLinks, false);
}
else
{
// not yet, let's wait a bit and try again
setTimeout(isLoaded, 300);
}
};
</script>
</head>
<body>
<iframe id="myframe" src="http://www.google.com" onLoad="isLoaded();" style="width: 100%;" seamless="true" nwdisable nwfaketop></iframe>
<div>
Links in the normal browser should still work in the Node Webkit environment.
</div>
<footer>
Whaddayaknow
</footer>
</body>
</html>

Receiving notifications for the Facebook Like button on my website

I'm trying to receive Facebook notifications (within Facebook) when a user Likes a post on my blog - http://visualise.ca.
I have the following code, the plugin works fine but I can't get notifications and I don't know what I'm doing wrong. Here is a sample of the code:
<html lang="en">
<head>
<meta charset=utf-8>
<meta property="fb:admins" content="589865326" />
</head>
<body>
<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=134951483245924&xfbml=1"></script><fb:like notify="true" href="http://visualise.ca" send="true" layout="button_count" width="450" show_faces="false" colorscheme="dark" font=""></fb:like>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({appId: '134951483245924', status: true, cookie: true, xfbml: true});
FB.Event.subscribe('edge.create', function(href, widget) {
// Do something, e.g. track the click on the "Like" button here
});
};
(function() {
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
</body>
</html>
What am I missing? Many thanks for your time and help.
FB.Event.subscribe('edge.create', function(href, widget) {
// Do something, e.g. track the click on the "Like" button here
});
To get "notifications" (not Facebook notifications as they don't exist for the like button), this is where you can AJAX back to your server that someone liked the page.