Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have an HTML5 game on my site, and at the end, I want the user to have the option of posting their score to their Facebook wall. Is there an easy way to ask to post something to Facebook?

share|improve this question
1  
+1 for a neat idea. –  Randolf Richardson Jul 18 '11 at 3:38
add comment

3 Answers

You can use the Facebook Graph API for that purpose (there are several SDKs available).

These are roughly the things you need to do:

  • Create an app on Facebook. You can do this here. There you'll get your APP and API Keys that are needed for you to communicate with the Graph API.
  • If your app wants to post to somebodies wall, he/she needs to grant your app that permission. For that you'll need authentication, specifically your app needs to ask for permission to write the users stream (publish_stream)
  • If the user granted you permission, your app can then publish to his wall using the Graph API (read the section titled Publishing). If the user doesn't grant you permission, don't nag any further :)
share|improve this answer
add comment
up vote 4 down vote accepted

You don't kneed to place a log-in button, and you don't need to set permissions. I found this Stack Overflow question that explains a quick way to do it just in javascript. The user is asked post the item to their wall, and they can either add a message and post or just skip it.

share|improve this answer
    
+1. That's actually a good way to achieve what you want. FYI: You don't need special permissions for this, as the message will be displayed to the user beforehand, so he can review/modify it before posting. This also means that he can modify the score that will be posted to his FB-wall though :) –  bummzack Jul 19 '11 at 6:40
    
@bummzack It actually won't let them modify the score if you put it in the title or the description. They only get to modify the message –  cstack Jul 19 '11 at 13:52
    
Is it also applicable for Eclipse IDE for Java developers associated with LibGDX? I'm making an Android game app that lets you post it onto the wall via Facebook as long if the player got the new high score or achievements? –  David Dimalanta Jan 10 '13 at 5:31
add comment

To post on the user's wall, first register the app with Facebook. Set it up as a webpage app, even though it will be on your website and not theirs.

Now you can put a button on your site that will log the player into Facebook and then the game can post messages on their wall.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.