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 publish a likes of a page to the user using the og Tags? #42

Closed confile closed 11 years ago

confile commented 11 years ago

I have a website with articles and on this site there is a "This is a good article"-button. If a user clicks on this button I want to publish something like "Username finds ArticleName good on WebsiteName". It is very similar to a like.

Do you have any idea how to handle this?

benorama commented 11 years ago

For this, you need to create an app and define open graph actions. Check out the docs: https://developers.facebook.com/docs/concepts/opengraph/

It's a pretty complex topic... And you'll have to wait for Facebook to approve your actions / object types before launching the app on prod (but you can test them in dev mode).

On the Grails side, you'll create an action like this:

try {
    def result = facebookGraphClient.makePostRequest("${userFacebookId}/${appNameSpace}:${actionName}", parameters)
    if (result && result['id']) storyId = result['id'].toLong()
} catch(FacebookException exception) {
    log.warn(exception)
}