@beyondthetech, I do not know when the score would start showing up on the timeline or activity.
@matias.kiviniemi, I haven’t tried FB Achievements. If you sort it out, let us know how it works.
Naomi
@beyondthetech, I do not know when the score would start showing up on the timeline or activity.
@matias.kiviniemi, I haven’t tried FB Achievements. If you sort it out, let us know how it works.
Naomi
Ok, I’m getting a little closer.
On their Scores API page, Facebook says,
“Note that this API is only available to applications categorized as ‘Games’. You can categorize your app as ‘Games’ in the Developer app by navigating to About > Basic Info and selecting 'Games` in the drop down menu in the category field.”
However, there’s no setting there. Are they referring to the App Details page, which it does appear there, and do you need to “Submit App Detail Page” before scores will show up, even on your own timeline for debugging purposes?
Hey, @beyondthetech, your guess is my guess. I have not submitted the app detail page yet. My latest game app is approved by Apple, but I haven’t released it yet, and because it’s not released, I wasn’t sure if FB question “What platforms are listed for your app in App Center” would cause me problem by submitting before the app is available for sale. But maybe I’m over thinking it. Who knows?
Naomi
P.S. After all said and done, maybe you can put together FB Score API how-to for everyone, especially since you’ve just gone through it and have a fresh memory/experience to draw upon.
Hey, SegaBoy, have you looked into Facebook Score API? Facebook returns JSON object with the list of FB friends who posted score, and it’s already sorted by highest score to the lowest score. All I do is just display it based on the JSON data I get from FB.
When posting my own high score, I use this:
[lua]
local attachment = {
score = tostring(myhighscore),
access_token=mytoken
}
facebook.request(“me/scores” , “POST”, attachment)
[/lua]
When retrieving JSON object with list of friends and their scores, I simply call:
[lua]facebook.request(appID … “/scores”)[/lua]
The response I get from FB would be handled by json.decoding the event.response:
[lua]
local response = {}
response = json.decode( event.response )
[/lua]
You might want to print the event.response on terminal/console and see what it prints. It should give you enough information as to how you may want to make use of the JSON object that FB sends you back.
I hope this helps and is relevant to what you are trying to do…
Naomi
Hi Naomi - so from what I can surmise from your post and the Facebook dev page it seems as though I didn’t need to go to the lengths of setting up a server, database, php scripts, etc… *MAJOR FACEPALM* :)
Am I right in assuming that you send a score to Facebook and they’ll handle it - no need for us developers to have an external database? Then I just handle the requests like you’ve shown above?
Can’t believe how easy this might be and if so how stupid I’ve been re-inventing the wheel
Naomi - just before I shut down my server and scrap my PHP scripts - I just wanted to make sure this approach would serve the purpose I’m intending - which is imply a leader board showing a user’s FB friends scores?
Many thanks,
Hey, SegaBoy, yes, I use it to show the leader board of FB friends. If your friends are not posting score to Facebook from your app, they won’t show up. So if you are the only person in the circle of FB friends that post score using FB score API from your app, FB will send back JSON object with your score data and nothing else. However, as soon as your friends start posting their score, his/her score will come back along with yours.
One thing I noticed, though, is that after I delete and reinstall the app and post a new high score to FB, even if the new high score is actually lower than the one posted before reinstalling the app, FB will only record/retain the most recent score posted, which is different from how it works with iOS Game Center.
BTW, you don’t have to shut down your server and do away with your PHP script. Why don’t you give FB score API a shot, and if it doesn’t work the way you envision, you can always resume with your server work.
Naomi
Naomi, you’ve piqued my interest in having my next game post scores to Facebook. If I get this correctly, it’s not posting a status update that you’ve scored, but there’s an actual scoreboard on Facebook that is automatically sorted and retrievable from a Facebook request?
Has anyone posted direct instructions or steps on how to get this done? Does this need an Open Graph or special App settings in Facebook’s developer pages? I saw your code and I see your passing a variable called mytoken. I don’t see any reference here on what it is or how to get it.
I think I’ve done simple posting and uploading photos a while back, but this seems like something new (at least for me) that I’d like to try to integrate. Can you provide some direction or more of your code? Thanks.
Hey, BeyondtheTech, when your app connects to FB (definitely when app invokes facebook.login, and maybe when facebook.request is fired, but I’m not 100% sure), you get a event.token back from FB. That’s the token you want.
If you’ve done simple posting and uploading photos before, it shouldn’t be all that difficult to get FB Score API working. Remember to set the permissions correctly at FB dev page for your app. publish_streams permission is now deprecated. You need to use publish_actions instead. Also, you can no longer post messages on friends wall unless you use facebook.showDialog function.
Naomi
Thanks. I’ll give it a shot. But, I’m hoping someone could come up with a complete run-through for Corona’s Facebook integration. It seems like it’s gone through a few iterations, but the documentation is in pieces over various sections throughout the site (and off the site) over the last few years.
@BeyondTheTech -agreed, wish CL would allow some kind of public access on the documentation side. I can understand not opening it up entirely, that only works if you’ve got a lot of people keeping an eye over things. However what Naomi has said would have saved me a day!
Also, I read on another forum thread that you can’t use
"me/scores"
but you have to use
userID .. "/scores"
. Which is correct? Very sparse and confusing stuff here.
facebook.request(“me/scores” , “POST”, attachment) works fine with my app. But then, I can also imagine how userID … “/scores” may work too. I suppose it depends on how you set things up.
Naomi
Plugging in my iPhone to Xcode’s Organizer, I see this when it’s trying to perform the high score post.
I'm getting Error: HTTP status code 400 The operation couldn't be completed. (com.facebook.sdk error 5.)
When I had those, I googled “HTTP status code 400”. If I remember correctly, I think it has something to do with making FB request with wrong syntax and/or parameter.
Naomi
Edit: What daily build are you using? There was FB SDK update integration issues with earlier daily builds. I don’t remember which one fixed it, but it was definitely fixed by 1041.
I’m on the latest 1055.
@beyondthetech, then, if I were you, I’d look at the attachment table and see if there’s any syntax error there.
Edit: I’d also double check on the FB dev center and make sure all settings, including the permissions, are properly set. And remember, it takes time to propagate after you save the app on FB.
Edit2: Also, if you are making facebook.request that is no longer allowed by FB, you could get an error too.
Naomi
All of the documentation should have links at the bottom that lets you give a thumbs up or a thumbs down and report problems like outdated and incorrect, incomplete entries. I’m not sure the guides have that and I know the blogs don’t.
You can always email support AT coronalabs DOT com for the things that don’t have the reporting feature.
As for Jon’s blog. That was probably written before we had a Facebook API library that uses their Single Sign on facilities and may be why you have to jump through all of that web hosting stuff.
I can’t speak for everyone, but I think most of the main features of Facebook integration are well understood by most of us now, but it’s just the few things like loading a scoreboard and posting a score that really isn’t documented anywhere here, unless I just can’t find it.
Considering that most of Corona’s developers are game developers, I would figure this would be more discussed or “advertised,” so to speak. Also, I’m not sure what settings or permissions are exactly required on Facebook’s Developers page, and there was no mention of scoreboards in any of the settings pages there, and any possibly-related permission settings are vague enough for me not to know if I need to set it one way or the other.
the problem i had with posting facebook scores was solved after i realized you needed to post the score as a STRING!