(Unity iPhone) Help With Online Leaderboard Using Facebook Connect

Hi all,

I looked on the forum and nobody seems to have addressed this issue...

I want my game to have an online leaderboard utilising facebook connect so that I can show a player how he has scored compared with his facebook friends. I'm unsure of how to start implementing this within Unity.

I realise that i'll need to create a page or two on the web server in PHP to handle database inserts to store the high scores and user facebook id's, and also to make wall posts for users (informing friends of their new high score, as well as notifying other friends who play the game that their score has been beaten).

What I don't know how to do is add the facebook connect bit within Unity that will allow me to access a user's facebook data (friends list, profile pic etc), or how to submit a piece of data to the web server to store a user's score against their facebook ID... I also don't know how I go about getting the high scores INTO unity from the server? I was assuming i'd just have to have Unity goto a webpage in the background (www.domain.com/mygame/getscores.php?playerID=###) and this page would return a load of XML which unity would parse and then I have my scores ready to output into a nice looking leaderboard... I guess what i'm asking, is how you get Unity to make a server request?

Sorry this Q is a bit wordy, but hopefully someone can help.



AFAIK facebook connect doesn't let you access user data from server requests, you have to actually visit (or embed) their javascript based login system thing, specifically to prevent automatic access of data. Take a look at their API - If there is a way to connect using server requests, I'd love to see it.

Here is the Objective-C iPhone facebook connect system Facebook Connect iPhone

To answer your question, I hope:

The Unity API classes you need to get and post data are WWW and WWWForm

I wrote a blog post yesterday on getting facebook connect working in a unity game, with sample code from start to finish. I was also thinking about how it would lead into a leaderboard system. That would be something good to add in an upcoming post.