Facebook Open Graph - Share Dialog not appearing from Facebook Application - facebook

Implementing Share feature on web application.
While the code below works with your favorite desktop and mobile browsers (Share Dialog shows up when clicking on the Share button), it wont work (the Share Dialog doesn't show up) when the web application is opened via Facebook Android Application (by clicking the Website URL from a post and it open's up from the website)
FB.ui({
method: "share_open_graph",
action_type: "og.shares",
action_properties: JSON.stringify({
object: {
"fb:app_id": "my_app_id",
"og:url": "url_of_my_app",
"og:title": "my_app_title",
"og:description": "my_app_desc",
"og:image": "display_image",
"og:image:width": "600",
"og:image:height": "350"
}
})
}, function (response) {});

Rule of thumb when using FB.ui is to not use FB.ui inside a Promise success callback. Facebook Application is blocking pop-ups when called inside a successful return of Promise.

Related

Facebook Feed Dialog does not work on Chrome/Android native app

I am developing a Facebook Canvas App which allows user to post a link to their wall:
function postFeed(){
FB.ui({
method: 'feed',
link: 'https://apps.facebook.com/?????',
name: '?????',
description : '?????',
picture: '?????',
}, function(response){});
}
It works fine on desktop (all browsers including desktop Chrome) and mobile Firefox. However when I use mobile Chrome or Android Facebook App's internal browser to open it, the following message shows up when I run postFeed() and be redirected to the feed dialog:
An error occured. Please try again later.
API Error Code: 110
API Error Description: Invalid user id
Error Message: Missing user cookie (to validate session user)
postFeed() is called after I run the following code:
FB.login(function(response) {
if (response.authResponse) {
alert("Welcome!");
}
}, {scope: 'public_profile'});
However if I remove the above code, the error message disappears and I can see the feed dialog normally.
Is there any possible reasons/solution that can solve the problem but without removing the above code?
Thank you very much.
I use 'share' instead of 'feed' method and the problem is gone.

Facebook API: Can't have the send dialog working. Why?

I am trying to send a message to a user through private inbox with Phonegap and the phonegap facebook plugin through this functionality:
https://developers.facebook.com/docs/sharing/reference/send-dialog
So when doing this :
FB.ui({
app_id:'XXXXXXXXX',
method: 'send',
name: "This is the name",
link: 'www.google.com',
to:to,
description:'This is the description'
});
as stated in this link : Send private messages to friends
Nothing happen. Why ?
Is it supported by the plugin ?
Please help.
Thanks
I am trying to implement the private message function in phonegap build, but it seems like its only working on desktop not in mobile device.
when I change the method from send to feed, and indicate display to touch.
It works on my IOS build, the window just popup
FB.ui({
app_id:'XXXXXXXXX',
method: 'feed',
link: 'www.google.com',
to:to,
display: touch
});
However, its not working any more when I change the method back to send.
I believe facebook api don't support FB.UI send method in mobile devices, just like what they already mentioned on their page: https://developers.facebook.com/docs/sharing/reference/send-dialog
"This dialog can be used with the JavaScript SDK and by performing a full redirect to a URL. It is not supported on mobile devices."
I STILL DON'T KNOW HOW TO SEND PRIVATE MESSAGE THROUGH FACEBOOK NOW, GOOD LUCK

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

calling $.ajax without having my canvas page being redirected to post url

I want to submit a form from my Facebook canvas app via ajax.
If I run my app outside of facebook, it works fine. However, if I do the ajax call running as a Facebook canvas app, the user is redirected to the the ajax post url!
The server response is valid json.
I've spent over an hour on this.
I found that Facebook has a deprecated FBJS ajax api. The new js api does not provide any ajax functionallity. The documentation on the deprecated API listed above states:
If you are building a new app on Facebook.com, please implement your
app using HTML, JavaScript and CSS.
What is the magic recipe to make an ajax post from a canvas app?
The relevant code boils down to this:
$(function () {
$('form').submit(function () {
if ($(this).valid()) {
$.ajax({
url: this.action, // I tried also submitting to the apps.facebook.com/... url, but it made no difference
type: this.method,
data: $(this).serialize(),
success: function (result) {
$('#result').html(result);
alert('TESTING - WORKS!!');
}
});
}
return false;
});
});
A night's sleep does wonders to your mind. It was very late yesterday when I posted this question.
When I woke up this morning I knew what to check for. The action I was posting to via ajax was in a controller that required Facebook authentication... Moved the action to a different controller and it now works. solved

Facebook JS SDK - Request UI

I am trying to create a Facebook Request Dialog with JS SDK inside a Facebook page iframe tab. The dialog shows up, I can select people from my friends, I get no error not even after I click "Send Request", but my friends don`t receive the notification. This is my code:
FB.ui(
{
method: 'apprequests',
message: 'request'
}, function(response) {
console.log(response);
});
LATER EDIT: I uploaded a file with exactly their code from documentation on this tab: http://www.facebook.com/pages/WebTest/255282254520859?sk=app_230016043737427 , and my friends still can`t see the requests.
Have you run it with a Firebug / Chrome console open? Maybe an exception is being generated and dumped there.