1

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);
    }
}
Quintin Par
  • 15,862
  • 27
  • 93
  • 146
  • Any errors on the console? Same behavior in all browsers? Also, why do you put the values for `redirect_uri`, `next` and `app_id` yourself? The SDK will take care of that for you. – Nitzan Tomer May 24 '12 at 06:17

2 Answers2

7

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.

OGHaza
  • 4,795
  • 7
  • 23
  • 29
Sandeep Tawaniya
  • 717
  • 8
  • 17
  • 3
    Might not be the official way (no idea what is), but very clever. – mynameisnotallowed Nov 22 '12 at 14:54
  • 1
    Brilliant! A minor thing, but just to ensure a better user experience you might want to use a setTimeout to delay the window.close() and display some messaging to the user that their post was successful before closing the window. Also, you might want to use this JS snippet to close the window - http://stackoverflow.com/a/12896858/123545 – ErJab Apr 23 '13 at 22:05
  • 1
    Including jQuery is way too much, a simple `` is enough – Koen. May 26 '15 at 14:28
4

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

Dhiraj
  • 33,140
  • 10
  • 61
  • 78