agorapulse / grails-facebook-sdk

Facebook SDK Grails Plugin
http://agorapulse.github.com/grails-facebook-sdk/guide
30 stars 13 forks source link

How can I share a photo with facebookClient? #29

Closed confile closed 11 years ago

confile commented 11 years ago

How can I share a photo with the facebookClient? Is there a similar command like the publish, but for sharing?

benorama commented 11 years ago

No, I don't think that there a specific share functionnality in Facebook JS SDK, there is only a Feed Dialog : http://developers.facebook.com/docs/reference/javascript/FB.ui/

mateuszbrzezinski commented 11 years ago

You can do it with this code:

function fbShare(share) { var w = 640; var h = 460; var sTop = window.screen.height/2-(h/2); var sLeft = window.screen.width/2-(w/2); var shareUrl = 'http://www.facebook.com/sharer/sharer.php?u=' + share; var sharer = window.open(shareUrl, "Share", "status=1,height="+h+",width="+w+",top="+sTop+",left="+sLeft+",resizable=0"); }

share parameter is url to share.

Benorama, you can implement it in library

benorama commented 11 years ago

Indeed you could use the legacy sharer, even if it looks like this is not really supported by Facebook anymore.

Note: be careful with window.open, you might get blocked by popup blockers.

confile commented 11 years ago

@brzezi How can I use your code with the plugin? Can you give a more detailed example?

mateuszbrzezinski commented 11 years ago

With this snap of code you dont need plugin, just add that function fbShare as javascript function somewhere on your page or in js file, then in onClick event you can call fbShare('http://some.url.to.share.com');