So I use Cocos IDE with lua for creating my apps.
Also we use the facebook plugin that comes along with cocos2d-x.
My Problem is rather special i guess… at least i was not able to find a solution in the forums/net.
Sometimes we use the graph api calls (requests) from facebook to get, post, share our information with the users that play our games.
Recently we discovered this useful call: [Score API][1]
So we wanted to implent this call into our game.
In lua you would write it like this then:
plugin.FacebookAgent:getInstance():api(path, type, params, callback)
as we use the score api:
plugin.FacebookAgent:getInstance():api("/me/scores", POST, { score = 1000 })
as an example. The problem is:
This call requires the variable “score” to has a integer value. As you can see in this case score is an integer.
But as soon I send this table facebook does send me an error back that score is not an integer.
After some reading in the plugin source I found this part: (Source: UserFacebook.java)
JSONObject jsonParameters = info.getJSONObject("Param3");
Bundle parameter = new Bundle();
Iterator<?> it = jsonParameters.keys();
while(it.hasNext()){
String key = it.next().toString();
String value = jsonParameters.getString(key);
parameter.putString(key, value);
}
Param3 here is my table that gets converted into a bundle. However as you can see all the values of each key get converted to a string. The bundle then gets finally send to facebook as a request.
Request request = new Request(Session.getActiveSession(), path, parameter, httpmethod, new Request.Callback() {...}
Did I found at least the root of the problem or does it has another problem I do not understand for that my lua number does not get handled as an integer?
PS: My english is… well - you probably have realized it already - not the best. So I apologize for it.
[1]: https://developers.facebook.com/docs/games/scores