Login with JS and then using PHP SDK (Facebook) - facebook

I'm using this code to login my website via facebook:
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId:'MYAPPID', cookie:true,
status:true, xfbml:true
});
</script>
<fb:login-button>Login with Facebook</fb:login-button>
Its working well and I see my application on facebook.com/editapps.php, but then when I want to start using PHP SDK I see that I didn't login. If I login via PHP SDK then I see that I logged in.. What is the problem here? Thank you.

What version of PHP SDK are you using? Because the latest 3.0.1 isn't compatible yet with javascript SDK. So you would need to downgrade to version 2 of the SDK until they will update the Javascript SDK too.
More info about this here: http://developers.facebook.com/blog/post/503/

Related

"Uncaught ReferenceError: firebase is not defined". How to define firebase and get beyond blank screen in Chrome?

I am integrating Flutter web into an existing app. The existing app functions as expected on iOS and Android. The app utilizes FlutterFire. With the below, when running to Chrome device I get a blank white screen.
pubspec.yaml
environment:
sdk: '>=2.6.0 <3.0.0'
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
firebase: ^7.3.0
firebase_core: ^0.5.0
cloud_firestore: ^0.14.0+2
firebase_analytics: ^6.0.0
firebase_auth: ^0.18.0+1
index.html
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.20.-/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/7.20.-/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.-/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.-/firebase-auth.js"></script>
<script>
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
var firebaseConfig = {
apiKey: "myKeyHere",
authDomain: "myDomainHere",
databaseURL: "myURLHere",
projectId: "myProjIDHere",
storageBucket: "myBucketHere",
messagingSenderId: "myMessageID",
appId: "myAppID",
measurementId: "myMeasID"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
firebase.analytics();
</script>
<!-- This script installs service_worker.js to provide PWA functionality to
application. For more information, see:
https://developers.google.com/web/fundamentals/primers/service-workers -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('flutter_service_worker.js');
});
}
</script>
<script defer src="main.dart.js" type="application/javascript"></script>
</body>
This results in the following error in the VSCode console:
TypeError: Cannot read property 'app' of undefined
at Object.app$ [as app] (http://localhost:58913/packages/firebase/src/top_level.dart.lib.js:78:89)
at new cloud_firestore_web.FirebaseFirestoreWeb.new (http://localhost:58913/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:755:57)
at Function.registerWith (http://localhost:58913/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:671:73)
at Object.registerPlugins ...
and the following error in the Chrome console:
Uncaught ReferenceError: firebase is not defined
at localhost/:50
:58913/packages/firebase/src/top_level.dart.lib.js:78 Uncaught (in promise) TypeError: Cannot read property 'app' of undefined
at Object.app$ [as app] (:58913/packages/firebase/src/top_level.dart.lib.js:78)
at new cloud_firestore_web.FirebaseFirestoreWeb.new (:58913/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:755)
at Function.registerWith (:58913/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:671)
at Object.registerPlugins (:58913/packages/carlinehound/generated_plugin_registrant.dart.lib.js:23)
at main (:58913/web_entrypoint.dart.lib.js:29)
at main.next (<anonymous>)
I have used both the Future Builder and Streambuilder FlutterFire app initialization methods. I have also simply initialized in main(). All of these result in the same error.
The problem obviously is that firebase is not defined. My question is how do I define firebase?
You didn't specify a full version number when adding the JS SDK in your index.html
7.20.- is not a real version, it's just a placeholder for you to specify the one you want to use.
You can check this by going to the src in your browser. You'll see that the srcs you currently have will not exist. The ones I show below will show a bunch of JS.
If you want to use the latest version, that would be 7.20.0.
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-app.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#available-libraries -->
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-auth.js"></script>

Blank page running Angular 9 app on ios 13

I have issues loading my Angular 9 app on iPhone, it loads in all desktop browsers and android devices, just got an blank page in iPhone. It raises an promiseReactionJob exception in the polyfills-es2015 file .. running the lasted iOS version (13.4.1). I see the in the index.html, the scripts are loaded as expected.
<script src="runtime-es2015.c741d58c5f0062b819ef.js" crossorigin="use-credentials" type="module"> </script>
<script src="runtime-es5.c741d58c5f0062b819ef.js" crossorigin="use-credentials" nomodule defer></script>
<script src="polyfills-es5.1e423cd55d051bbc2156.js" crossorigin="use-credentials" nomodule defer></script>
<script src="polyfills-es2015.367a122fcc429806387a.js" crossorigin="use-credentials" type="module"></script>
<script src="main-es2015.80003c523586b89abce8.js" crossorigin="use-credentials" type="module"></script>
<script src="main-es5.80003c523586b89abce8.js" crossorigin="use-credentials" nomodule defer></script>
It is production build: ng build --prod
The error below:
Or, disabling the --prod
The issue was due Safari/iOS doesn't implement addEventListener/RemoveEventListener, so the app called an undefined method and raised the exception. My fix was to add an iOS check and call addListener and removeListener only on iOS as addEventListener/RemoveEventListener were not in fem2015/layout.js loaded by Safari on iOS (tried iOS >= 12).

Ionic state change issues on iOS 9 post version update to 1.1.1

Confirming that i have updated Ionic to 1.1.1, so assuming the iOS9 webview patch is included in it. However, i am still facing issues with side menus onclick of which i am invoking $state.go() which does not render the actual page & reverts to original state. UI is completely broken.
Below is the system information:
Cordova CLI: 5.3.3
Gulp version: CLI version 3.9.0
Gulp local:
Ionic Version: 1.1.1
Ionic CLI Version: 1.7.10
Ionic App Lib Version: 0.6.5
ios-deploy version: 1.8.3
ios-sim version: 5.0.3
OS: Mac OS X El Capitan
Node Version: v0.12.7
Xcode version: Xcode 7.1.1 Build version 7B1005
HTML Code in the side menus:
<ion-item menu-close href="#" ng-click="getWishlist()" ng-if="userId && userId != ''">
<div class="row">
<div class="col col-20">
<i class="ion-heart"></i>
</div>
<div class="col col-80">
My Wishlist
</div>
</div>
</ion-item>
JS Code in getWishlist():
$scope.getWishlist = function (){
$state.go("app.wishlist", {}, {reload: true});
}
Help appreciated!
Note: Static URL invocations within menu seem to work just fine!
<ion-item nav-clear menu-close href="#/app/contact-us" >
<div class="row">
<div class="col col-20">
<i class="ion-ios-telephone"></i>
</div>
<div class="col col-80">Contact Us
</div>
</div>
</ion-item>
Well, i guess it was my bad for not reading this post properly!
I figured the issue was due to href='#'. The post does mention to remove empty href links if necessary which invoke the otherwise state in iOS 9. Once i removed them the links started to work as expected.
However, i still had to alter my CSS to make the side menus look proper.

phonegap 3.0 facebook login

I m using phonegap 3.0 and trying to install the below faceook login plugin:
https://github.com/phonegap/phonegap-facebook-plugin
I have added the following changes in the config.xml file
<gap:plugin name="com.phonegap.plugins.facebookconnect">
<param name="APP_ID" value="[APP_ID]" />
<param name="APP_NAME" value="[APP_NAME]" />
But still when i am trying to install the plugin its giving me the following error:
Error: Variable(s) missing: APP_ID, APP_NAME
Can anyone tell me why this error might be occuring.M i missing adding any changes in some file.
Thanks
It looks like this plugin hasn't been rewritten for phonegap 3.x yet. Here is the issue on the github project where people are discussing it: https://github.com/phonegap/phonegap-facebook-plugin/issues/343
And here is where someone fixed the android part of the code to work with phonegap 3.x: https://github.com/phonegap/phonegap-facebook-plugin/pull/348
Also, here is where someone else was having trouble using it for iOS with phonegap 3.x: Phonegap 3.0.0 - Facebook SDK 3.6 - FB plugin: Facebook connect not found
On the instructions in the plugin readme it says:
6) Replace your appId in the new index.html file. Leave the quotes.
You can look in the examples folder and you'll see something like this:
document.addEventListener('deviceready', function() {
try {
alert('Device is ready! Make sure you set your app_id below this alert.');
FB.init({ appId: "appid", nativeInterface: CDV.FB, useCachedDialogs: false });
document.getElementById('data').innerHTML = "";
} catch (e) {
alert(e);
}
}, false);
Hope this helps
Plugin should be fully CLI compatible now on master branch.
Here is some sample code
cordova create myApp
cd myApp/
cordova platform add ios
cordova -d plugin add /Users/your/path/here/phonegap-facebook-plugin --variable APP_ID="123456789" --variable APP_NAME="myApplication"
Enjoy.
I met this problem too. Here answer https://github.com/phonegap-build/FacebookConnect/issues/21

Deviceready function does not fire in cordova 2.8.0 and cordova 2.7.0 while remote loading

I have been trying to call the files from the server side for phonegap for ios.But deviceready function does not fire in cordova 2.8.0 and cordova 2.7.0 while remote loading.
If you run it on device, paths of your js are wrong.
Use relative paths, I read that absolute paths are difficult to get with iOS.
So something like this (just a sample) :
<script type="text/javascript" charset="utf-8" src="../cordova-2.7.0.js"></script>
<script type="text/javascript" charset="utf-8"src="../js/index.js"></script>
Anyway, if you want more help, please give us more details of your issue (description, error message, code, ...)
By the way, have you any error message ?