Tutorial: Facebook Friends Leaderboard

I decided to start a simple website (iDeveloper) for the sole purpose of posting tutorials and code on how to do things in Corona that you really can’t find anywhere else at the moment.

At first, I simply wanted a place to keep track of how to do some of the more advanced things I figure out so I didn’t have to keep looking at the source of my previous projects, but I decided to make it public so everyone can benefit from it.

My first is an in-depth tutorial that shows you how to implement a Facebook Friends Leaderboard that’s very similar to what you see in games like Doodle Jump and Bejeweled Blitz. I think it makes games much more competitive and addictive when you can see your score up against your friends.

So without further ado, here’s the link to the tutorial:

–> http://ideveloper.kodingen.com/2010/facebook-friends-leaderboard/

Comments are turned off on the blog so please reply to this thread if you have any questions or comments regarding the tutorial! [import]uid: 7849 topic_id: 2432 reply_id: 302432[/import]

Hi!

Thank you very much for this nice tutorial. I will give it a try as I see this as a good feature for android games and Iphoen as well.

Best wishes
Michael Hartlef

http://www.whiteskygames.com
http://www.twitter.com/mhartlef [import]uid: 5712 topic_id: 2432 reply_id: 7204[/import]

Thanks for taking the time to view the tutorial, Mike!

Let me know if you need any help and if/when you put it in any of your games! [import]uid: 7849 topic_id: 2432 reply_id: 7205[/import]

Yes, I will do that. [import]uid: 5712 topic_id: 2432 reply_id: 7207[/import]

jonbeebe Great site you started there. I like your and your wife’s tumblr blogs too. Since I’m on tumblr also I was able to subcribe to your blogs. [import]uid: 295 topic_id: 2432 reply_id: 7217[/import]

Wow! This is great Jonathan, just had a quick read through the tutorial and I’ll definitely be implementing this.

I want to give a big thanks to you too for posting the link to your Corona review on Touch Arcade a few weeks ago. It was because of this that I reacquainted myself with Corona after checking it out early on and was able to buy it just before the price rise :slight_smile:

I’m loving Corona and it has motivated me into action to finally turn my ideas into real games. So thanks again and I look forward to working through your tutorials, you are a great ambassador for Corona!
[import]uid: 9064 topic_id: 2432 reply_id: 7224[/import]

@tokyodan: Thanks a lot for your compliments, and for following us on tumblr! I hope you enjoy the content on the new site.

@bherron: Please let me know when you implement it in one of your apps! It’ll definitely feel good to see it in action elsewhere, to know someone really got some benefit out of it. I literally worked all night long trying to figure out how to do that (wrestling with JSON and the Facebook API was the worst, because I have little experience with both).

I’m also glad to hear that my Corona review had an effect on your decision! I didn’t mean to post it right before the price jump, but I guess that worked out well in Ansca’s favor :slight_smile: [import]uid: 7849 topic_id: 2432 reply_id: 7227[/import]

Hi jonbeebe. I am having difficulties on step 2. Facebook setup. I am confused about the site and site URL. I setup a website for my business and a page for the app but it won’t accept the URL saying it needs to point to a directory. Any suggestions?

Thanks [import]uid: 8192 topic_id: 2432 reply_id: 11685[/import]

great! thanks for sharing [import]uid: 6645 topic_id: 2432 reply_id: 11696[/import]

Was wondering if anyone could help. I followed the process step by step but I seem to keep getting “internal server error” messages. I am a complete beginner about php and mysql. I did set up a database through my hosting at godaddy and was able to create a new table as instructed. I have the suspicion that my issue is in the server name.

In the documents it says that it’s usually “localhost” but when I click on myphpadmin page for server it actually gives me an ip address. Anyways I tried both and get the same error, which doesn’t really give me much room for debugging.

Any help is appreciated and thanks a bunch again to jonbeebe for this tutorial.

Thanks [import]uid: 8192 topic_id: 2432 reply_id: 11705[/import]

Hey leo, sorry for the late reply.

Some hosts are a little different when it comes to the server address. Along with the IP address, does it also give you a port? [import]uid: 7849 topic_id: 2432 reply_id: 11708[/import]

@jonbeebe, just sent you an email. Thanks for the help. [import]uid: 8192 topic_id: 2432 reply_id: 11714[/import]

Hi Jonbeebe,
First of all, thanks for this tutorial, it’s very well written and easy to use.
I’ve created my facebook app, and my database, and I’m now trying to test your different scripts via my web browser. I managed to fill the database with 2 scores, by calling http://www.blabla.com/leaderboard/sendscore/?score=50
But now, when I try to load the following page :
http://www.blabla.com/leaderboard/loadfriendranks/?bestscore=50
My browser connects to facebook.com (ok), and then, I get the following warnings on my page, and my HighScore table is empty :

Warning: file_get_contents(https://graph.facebook.com/oauth/access_token?client_id=0000000000&type=web_server&redirect_uri=http%3A%2F%2Fwww.blabla.com%2Fleaderboard%2Ffriendranks&client_secret= 000000000&code=0000000000) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in /homez.358/–xxxx–/www/leaderboard/friendranks/index.php on line 56

Warning: file_get_contents(https://graph.facebook.com/me?) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in /homez.358/–xxxx—/www/leaderboard/friendranks/index.php on line 61

Warning: file_get_contents(https://graph.facebook.com/me/friends?) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in /homez.358/–xxxx–/www/leaderboard/friendranks/index.php on line 105

Warning: Invalid argument supplied for foreach() in /homez.358/–xxxx–/www/leaderboard/friendranks/index.php on line 112

Have you got any idea of what I did wrong ?
Thanks by advance,
Antoine [import]uid: 11936 topic_id: 2432 reply_id: 12585[/import]

Hey jonbeebe,
I seem to be having the same problem as amigoni - I am receiving an Internal Server Error. I’m pretty sure I have the MySQL db connections correct… Any idea on why I am receiving this error? Thanks for all your hard work on the project!

-David [import]uid: 10942 topic_id: 2432 reply_id: 24368[/import]

@nahir: It’s been a while since I took a look at this, but the Facebook options might’ve changed.

It sounds like they want just your domain name, which would be: bubblesonly.com

Also, this script isn’t entire secure (it actually can be easily hacked by outsiders to inject false scores), so if you get a chance, you might want to implement some sort of client-server security, or hire someone to do so. This script is bare-bones. [import]uid: 7849 topic_id: 2432 reply_id: 28211[/import]

Hey, beebe! I’m following your tutorial right now trying to implement a highscore list to my game. Great tutorial mate, very easy to follow!

Got 2 questions though… First, when trying to do this: “In the Web Site sub-panel, make sure your Site URL is set to the online location that your PHP scripts will be located. Ex. http://www.yoursite.com/yourgame2”, facebook gives me an error message.

“Validering misslyckades.
Webbplatsens domännamn: http://www.bubblesonly.com/scripts/ is not a valid domain.”

which basically means, validation failed. the websites domainname is not a valid domain. What am i doing wrong? I’ve bought the domain and i got a folder in the ftp called scripts, so that URL is valid?

Second, in friendranks/index.php, where i need to edit the database_server. Do i paste the whole URL of the database_server? I bought my domain from one.com and they provide a myPhpAdmin database with the URL https://dbadmin.one.com/ for log in. Should I paste this whole URL in there?
Thanks! [import]uid: 14018 topic_id: 2432 reply_id: 28210[/import]

Oh ok, but then why bother write a tutorial you advice people not to follow? :stuck_out_tongue:

Thanks for the warning! [import]uid: 14018 topic_id: 2432 reply_id: 28214[/import]

The tutorial is pretty old, but it still works really well!

I’m just giving a disclaimer, that if you intend to use for a serious game, you need to have some kind of security implemented. The script still takes care of most of the “hard stuff”, so its still very useful to many people.

The database server should be in your database admin. Most of the time, it is just localhost. [import]uid: 7849 topic_id: 2432 reply_id: 28215[/import]

Alright, thanks a lot :slight_smile: [import]uid: 14018 topic_id: 2432 reply_id: 28216[/import]

That is a very useful tutorial, but more importantly for me is that kodingden link. I’ve never heard of them before, very cool. [import]uid: 12108 topic_id: 2432 reply_id: 31714[/import]