Facebook share dialog not closing after feed post - facebook

I have a feed post JS as follows.
var feedObj = {
method: 'feed',
link: link,
picture: imagelink,
name: name,
caption: caption,
description: description,
redirect_uri: "http://"+(window.location.host)+"/",
next:null,
app_id: appid,
actions: [
{ name: text, link: link }
]
};
function callback(response) {
if(response){
}
}
facebook.ui(feedObj, callback);
How do I make sure the feed dialog that clicked to post closes automatically?
I have noticed that the callback is not fired always and this attempt below does not work always
function callback(response) {
if(response){
facebook.Dialog.remove(facebook.Dialog._active);
}
}

I have got a simple trick to close this dialog box. It is not a good way to do this type of work but it just worked fine for me.
Firstly you have to create a page on your server (e.g. closewindow.aspx) and paste this code in your page's body part.
<script src="js/jquery.js" type="text/javascript"></script>
<script>
$().ready(function() { window.close(); });
</script>
Than set redirect_uri parameter property to this page, like :
redirect_uri=http://www.yousitename.com/closewindow.aspx
Now this time in dialog box, this page will be called as redirecturl and the dialog will be closed automatically on page load.
I know this may be tricky but you know how it feels when got this working.

According to the documentation, next is not a parameter.
I understood that with redirect_uri callback is not being called.
Since redirect_uri is supported by most sdks you need not use it.
DEMO
Hope this helps

Related

Fb.ui method feed not working. Loading gif appears but no error message or anything

So I've been trying to implement a Fb method feed so that people can share songs from my website. But it doesn't work.
It pops up a loading gif in the dialogue and thats it. No error nothing. I've wasted a lot of time trying to figure this out but haven't been able to.
Here's the code,
share_obj = { method: 'feed',
link: "", redirect_uri: "",
picture: ",
name: "",
caption:"" ,
description: ""
}; FB.ui({method: "permissions.request", "perms": 'publish_stream'},
callBack);
function callBack(response) { if(response["perms"]=="publish_stream") { var obj = share_obj; FB.ui(obj,callback_share); } } function callback_share(response) { }
Does it have something to do with Facebook app migrations or app permissions?
So turns out, there s no need to ask for user permissions when invoking the Fb.ui method.
Permissions are only required when you intend to publish stories via the graph API.

Facebook Post Publishing without any Dialogue using Javascript SDK

I have been searching for facebook publishing without showing Dialogue.
While reading Facebook developers doc, there are several things which seems to answer the question but after using them, I concluded those are not for this functionality.
Display Modes: They are different type of display mode for dialogues, but there is no way to define if I don't want to show the dialogue.
Explicit Sharing: This seems to be most close. But there is no way to use it in JS SDK. And the parameter mentioned there, I tried in JS but no resolution.
Then here what came to be most successful for me, to use
methode: '/me/feed'
But the problem is, it says:
[User] shared a link
Which I don't want. I want a normal publishing, but without any dialogue to be displayed.
Code I am using for simple publishing is below:
function publishNewsFeed(picURL, name, caption, description)
{
var obj =
{
method: 'feed',
link: fbAppURL,
picture: picURL,
name: name,
caption: caption,
description: description
};
function callback(response)
{
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
Any help will be appreciated.
Thanks
-WI
Display Modes: They are different type of display mode for dialogues, but there is no way to define if I don't want to show the dialogue.
That would be nonsense – if you don’t want to use a dialog, then don’t use a dialog.
But if you want to use a dialog, then it has to be “shown” in some way – otherwise it would not be a dialog.
But the problem is, it says [User] shared a link Which I don't want.
That is current “bug” – if you supply action links with your post, it will show up normal.
https://developers.facebook.com/bugs/485696594791863
Try this:
function jesseSays(){
var body = 'Yeah science Mr. White!!';
FB.api('/me/feed', 'post', {
message: body,
link: 'http://www.neoapps.com.br',
picture: 'http://www.neoapps.com.br/assets/img/logo-big.png'
}, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
}

Facebook Logout issue

I'm using the following code to logout from Facebook.
string url = string.Format("https://m.facebook.com/logout.php?confirm=1&next={0}&access_token={1}",
ConfigurationManager.AppSettings["Facebooklogout"],
token)
Note :
ConfigurationManager.AppSettings["Facebooklogout"]="http://localhost:56481/MenUs.Web/REGISTRATION/userinterestgroups.aspx"
But instead of logging out, it's directing me to my Facebook profile page.
Please provide me a solution
There is m.facebook.com bug that says next is being ignored. You could always use https://www.facebook.com/logout instead.
Also your logout URL has to be in the domain of the app you registered on Facebook, localhost will not work.
string url = string.Format("https://www.facebook.com/logout?confirm=1&next={0}&access_token={1}",
ConfigurationManager.AppSettings["Facebooklogout"],
token)
Please take note above, the logout URL must be in the same domain as the app. So the above would not redirect to localhost:xxx
I have resolved the above issue long ago by using the following javascript on click of "Save Button".
<script type="text/javascript">
function logoutFacebook() {
}
window.onload = function () {
var ID = document.getElementById('hfID').value
FB.init({ apiKey: ID });
FB.getLoginStatus(handleSessionResponse);
}
function handleSessionResponse(response) {
FB.logout(handleSessionResponse);
}
</script>

Use Javascript to open download link when feed dialog box is successfully shared?

Can someone please explain to me how can I have a download link appear when a user presses the share button on a feed dialog box? I'm using the following code: (with my own information of course)
Post to Feed
<script>
FB.init({appId: "YOUR_APP_ID", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
I have no clue on how to do is: what code do I need so that when a user clicks "share" a download box appears? But if they click cancel a message pops up telling them they need to share first? I have posted a similar question before and I got an answer saying I need to use some sort of JavaScript but the problem is I don't know how or what to write? Can someone please show and explain the sort of JavaScript I need to me because I don't know how to use JavaScript one bit.
Thanks in advance for any answers/help!!
The callback function is executed when the user completes the feed post dialog, with either the "share" or "cancel" button. You can test for a "post_id" to see which action the user took. Then either show the download box or display an alert (or perhaps a more user-friendly message format).
Add a hidden download box element to your page with an id of "download_box":
<div id="download_box" style="display: none;">
Download Box (whatever that means) goes here
</div>
And replace your current "callback" function:
function callback(response) {
if (response && response.post_id) {
document.getElementById('download_box').style.display = 'block';
} else {
alert('You must share your post before you can download.');
}
}

Facebook Request 2.0

I am kind of confused on how to use the new facebook request dialog box. Using the below mentioned function opens a box and I am able to send the request to the user who receives it. But when the user clicks on the request nothing happens instead the user is redirected to an internal link:
http://www.facebook.com/?request_ids=105890902828361%2C105893002828151%2C105899456160839%2C105902046160580%2C105904092827042&notif_t=app_request
How to resolve the issue? (Canvas Page not defined in Settings but Canvas Url is)
function requestsDialog()
{
FB.ui({
method: 'apprequests',
message: 'Here is a new Requests dialog...',
title: 'example',
data: 'trackinginfo'
},
function(response) {
if (response) {
alert('Request was sent.');
} else {
alert('Request was not sent.');
}
}
);
};
You need to specify a Canvas Page. For example, if your canvas page is:
http://apps.facebook.com/test_application
Then the URL that user will go to when clicking on the request will be:
http://apps.facebook.com/test_application?request_ids=12020393994,129193929392
At which point you can use the Graph API to look up what the requests are using the id (documentation here)