Facebook messenger extension js doesnt load when there is adsense code - facebook

I am having a webview for my facebook messenger bot , but i am putting a google adsense ad inside the webview. However , there is a problem that when I am putting the ad , messenger extensions isn't calling the function
<script>
window.extAsyncInit = function() {
// the Messenger Extensions JS SDK is done loading
};
</script>
although i am doing everything as per the documentation . I don't know whats the issue of google adsense , is it stopping the async process inside the page ?

window.extAsyncInit will not fire when messenger_extensions is false.
Property messenger_extensions must be true if using Messenger Extensions.
https://developers.facebook.com/docs/messenger-platform/send-api-reference/url-button
"buttons":[
{
"messenger_extensions": true,
"type":"web_url",
"url":"https://petersfancyapparel.com/criteria_selector",
"title":"Select Criteria",
"webview_height_ratio": "full",
"fallback_url": "https://petersfancyapparel.com/fallback"
}
]

Related

Unable to fetch user using Facebook js sdk v2.10 on Firefox

I am trying to add facebook authentication on our website using Facebook Javascript SDK v2.10. My aim is to login via Facebook and then fetch the user which was authenticated.
The problem I am facing is that on Firefox, I am unable to fetch the authenticated user.
I have created a test page HERE
When you click on the button 'Login via Facebook', the FB.login function is called. When the response is received, I am calling the FB.api function. Following is my code
FB.login(function(response) {
let p1 = document.createElement('p');
p1.innerHTML = "FB.login response follows:<br>"+ JSON.stringify(response);
document.body.appendChild(p1)
FB.api('/me', {fields: 'id,first_name'},
function(response) {
let p2 = document.createElement('p');
p2.innerHTML = "FB.api response follows:<br>"+ JSON.stringify(response);
document.body.appendChild(p2)
});
});
In Chrome,the callback of FB.api is called and the response is received,but, in Firefox, this is not happening. Kindly help me figure out why this is happening
Ok. I was using Facebook sdk in Polymer app. The sdk documentation suggests adding the sdk initialization code in index.html.
But, for Polymer, you need to add the code in the connectedCallback method of your root app (my-app.html if you are using polymer-starter-kit)
For reasons unknown, the webcomponent-loader.js blocks Facebook initialization on Firefox, if sdk code is added in index.html.

facebook login api doesn't respond in phonegap wp8 app

I'm using phonegap 3.5.0-0.20.4 & wp8 platform. My FB.login call simply doesn't seem to do anything (no response). I checked other replies around similar problem, but none seem to help wp8 platform. Here is my sample code
FB.init({appId: "23...32", version: 'v2.0'});
FB.login(function (response) {
console.log(JSON.stringify(response);
}, { scope: "email" });
My login call simply doesn't go through. I do have webbrowser & device plugins installed on the phonegap app.
Any ideas?
There are deprecated documentation, try this
FB.login(['public_profile'], successCallbackFn, errorCallbackFn);
But this has no sense because facebook does not return callback functions on login after april's sdk update to version 3.14
Please let me know if facebook login will work for you.

Facebook Login with PhoneGap/Cordova App

I recently integrated the phonegap-facebook-plugin (https://github.com/phonegap/phonegap-facebook-plugin) into both iOS and Android (same app).
I want to do something that I believe to be simple: by-pass the call to native facebook for login/authentication and always use the web dialog. How does one go about accomplishing this?
My login code currently looks like this:
Init code:
//facebook initialization
FB.init({
appId: 'xxxxxxxxxxxx', //'<%#= FB_APP_ID %>',//'',
nativeInterface: CDV.FB,
useCachedDialogs: false
});
And the login call is:
FB.login(function(response) {
if (response.authResponse) {
// connected
me.signInFacebook({
token: response.authResponse.accessToken,
email: response.authResponse.email,
success: function (data) {
// hide login view and show tabview
form.destroy();
// continue whatever action was previously happening
me.continueAction(tabIndexBack, callback);
},
failure: function (response) {
// show errors Ext.Viewport.down('tabscontainerview').setActiveItem(3);
}
});
} else {
//go back
Ext.Viewport.down('tabscontainerview').setActiveItem(3);
alert('fb login error');
}
},{ scope: "email" });
Thanks for your help!!
I created a plugin to facilitate the connection between Facebook and phonegap without using Plugin Native only with Jquery:
https://github.com/studiosoton/faceGap
To bypass native FB login, you can make your own manual facebook authentication flow without using JavaScript SDK of the Facebook (https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/v2.3) via inAppBrowser or ChildBrowser plugins.
Your app must initiate a redirect to an endpoint which will display the login dialog:
https://www.facebook.com/dialog/oauth?client_id={app-id}&redirect_uri={redirect-uri}&response_type=token&scope=email
Facebook redirects people to the redirect_uri mentioned above and places an access token along with some other metadata (such as token expiry time) in the URI fragment:
https://www.facebook.com/connect/login_success.html#
access_token=ACCESS_TOKEN...
Your app needs to detect this redirect and then read the access token out of the URI. You can then skip straight to the Inspecting access tokens step.
On the Android version of the plugin, you can force it to use the dialog by modifying the way the plugin calls me.facebook.authorize in the login action of theorg.apache.cordova.facebook.ConnectPlugin class.
You'll need to pass in an additional activityCode parameter with Facebook.FORCE_DIALOG_AUTH:
me.facebook.authorize(cordova.getActivity(), me.permissions, Facebook.FORCE_DIALOG_AUTH, new AuthorizeListener(me));
I'm not entirely sure about iOS, but you might be able to try with openWithBehavior and FBSessionLoginBehaviorForcingWebView
Without any Facebook plugins you can use Facebook functionality,for that use phonegap.facebook.inappbrowser.js using this js you can easily access all Facebook functionality for more information visit this URL : Facebook Integration Step without any plugins

fb:login-button ignores scope?

I changed my Facebook App to OAuth 2.0. Now the Login window ignores the user permissions.
The new login button code is as follows:
<fb:login-button show-faces="true" width="400" max-rows="2" scope="read_stream, publish_stream, email"></fb:login-button>
when I use perms instead of scope it works.
I have oauth:true in FB.init(). In the app settings oauth2 is active.
(Everything I did and learned was in an effort to be able to publish to a Facebook Timeline from a 3rd party website. I don't know your motive/goal. It might not be the same as mine.)
I am using JS SDK with javascript commands, not xfbml markup.
I am using the beta version of the JS SDK: set the host to connect.beta.facebook.net instead of connect.facebook.net
I have oauth:true in my FB.init() function.
I have app settings for OAuth 2.0 enabled at developers.facebook.com.
This is my FB.login():
FB.login(
function(response) {
if (response.authResponse) {
// handle a successful login
}
},
{
scope: 'publish_stream' // I need this for publishing to Timeline
}
);
One thing I did to debug this was to check the value of FB._oath. If it is undefined, you have a problem. If it is true, you can proceed to the next challenge.
So after lots of trial and error, I finally got FB._auth===true

webview is not redirecting anymore (Facebook API in webos)

I am trying to implement the possibility to post on your facebook wall from my app. http://developers.facebook.com/docs/authentication/ web application section.
It used to work. What i did was open the following URL in a webview
"https://graph.facebook.com/oauth/authorize?client_id=123456789123456&redirect_uri=http://www.mydomain.com&scope=publish_stream&display=wap"
And after the user typed his credentials and gives me the neede permissions, the webview was redirected to the redirect uri (www.mydomain.com) including a get variable from which i parsed a code which is needed.
But all of a sudden i am not redirected to the redirect_uri anymore. I am redirected to a blank facebook page (http://m.facebook.com/connect/uiserver.php)
It DOES work on a PC Browser and even in the webos browser, but not in the webview.
I even wrote a complete new application with nothing but a webiveiw in it. The main-assistant.js looks like this.
function MainAssistant(argFromPusher) {
}
MainAssistant.prototype = {
setup: function() {
Ares.setupSceneAssistant(this);
console.log("setup");
//this.controller.get("facetimes").mojo.clearCookies();
//this.controller.get("facetimes").mojo.clearCache();
this.controller.get("facetimes").mojo.openURL("https://graph.facebook.com/oauth/authorize?client_id=123456789&redirect_uri=http://www.mydomain.com/callback&scope=publish_stream&display=touch");
this.controller.listen("facetimes",Mojo.Event.webViewTitleUrlChanged,this.titleChanged.bind(this));
},
cleanup: function() {
Ares.cleanupSceneAssistant(this);
},
titleChanged: function(event){
console.log(event.url + " DAS IST DIE URL");
}
};
Any ideas?
Thanks in advance.
Blockquote
I wrote up the entire SDK with facebook api example on my blog
Facebook Connect WebOS
It's open sourced, the guide will give you the github address