Sharrre icon indicating copy to clipboard operation
Sharrre copied to clipboard

Add enableFeedDialog parameter to Facebook button

Open arnaudbreton opened this issue 12 years ago • 5 comments

I added a parameter named "enableFeedDialog" to the Facebook button which will open a Feed Dialog (https://developers.facebook.com/docs/reference/dialogs/feed/) instead of open a popup pointing to the sharer.php which is deprecated.

arnaudbreton avatar Dec 20 '12 12:12 arnaudbreton

I was trying out this and got the error says: FB is not defined.

Please notice that app_id and redirect_uri are required.

https://developers.facebook.com/docs/reference/dialogs/feed/

also says "You can also bring up a Feed Dialog by explicitly directing the user to the /dialog/feed endpoint"

see the Direct URL Example

yuanzhou avatar Dec 20 '12 16:12 yuanzhou

FB is not defined because you didn't initialize it before ? It's strange that you got an error, my test look that FB is defined before calling it.

In my web app with FB initialized all is OK.

You're right about the dialog/feed endpoint but the feed build by the ui method is directly shown in the current page.

Maybe I can open this endpoint if FB is undefined ?

arnaudbreton avatar Dec 20 '12 21:12 arnaudbreton

I just tried to use the link directly and it worked. Check out digg.com and all the FB feed dialog links are using the direct links with a redirect_uri which contains javascript window.close.

yuanzhou avatar Dec 20 '12 21:12 yuanzhou

Ok so I think that I can improve my pull request by adding a parameter to control the way the feed dialog is displayed (FB.ui vs direct link).

As you suggested, we can also add this simple self-closing page.

Are you OK with that ?

arnaudbreton avatar Dec 21 '12 07:12 arnaudbreton

That would be great! I customized mine yesterday and added app_id and redirect_uri for the users to define, so that they don't have to hard code them in the plugin, for example:

buttons: {
    facebook: {
        enableFeedDialog: true,
        app_id: '',
        redirect_uri: 'http://www.yourdomain.com/fbshare_self_colse'
    }
}

There are many other ways to do this, totally up to you.

Happy Xmas!

yuanzhou avatar Dec 21 '12 13:12 yuanzhou