[SOLVED] Saving user highScore with Facebook

Hi,

I want to save my user highScore with facebook and to do that i have written following graph api

sdkbox::FBAPIParam params;
params.insert(std::pair<std::string, std::string>("score", “100”));
sdkbox::PluginFacebook::api("/me/scores", “POST”, params, “UserScore”);

But the game crashes as soon as this is executed with the following error

*** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘*** setObjectForKey: object cannot be nil (key: message)’
*** First throw call stack:
(0x22c6e2eb 0x2243adff 0x22b892a9 0x56865b 0x587b79 0x58da3f 0x2347252d 0x233d3eff 0x233c62ef 0x234747ed 0xececab 0xed3771 0x22c30fc5 0x22c2f4bf 0x22b81bb9 0x22b819ad 0x23dfbaf9 0x26e6dfb5 0xdde17 0x22834873)
libc++abi.dylib: terminating with uncaught exception of type NSException

What is it that i am doing wrong here ?

Hello @ankitdm

Do you mean to do something like this as in the screenshot… ??

If so, then you are using it the wrong way.
Please check the thread below, I have implemented this in one of my game -

Best,
Pabitra

No, i don’t want to publish user score.

I want my score to be saved with Facebook game, to create a leaderboard of my facebook friends.

Please see this link for reference
https://developers.facebook.com/docs/games/services/scores-achievements

Not sure though let me check.
I see in the link that you have sent, the second parameter i.e. the number 100 is supposed to be an integer as Fb parameter asks it to be.

Does that make any difference, could you check and let me know please.

Best,
Pabitra

yes it is supposed to be an integer,

but, as sdkbox::FBAPIParam is defined as

typedef std::map<std::string, std::string> FBAPIParam;

so it only takes string as both the parameters.

Also i have tried the other way of defining the FBAPIParam, like

sdkbox::FBAPIParam params {{“score”, “100”}};

But this also doesn’t help.

Let us ask @Ibon to help us here.

@Ibon please help as i am kind of stuck and wasted almost a day to resolve this.

My bad, the issue was very simple and is now resolved by giving Publish permissions to user

Thanks for your help :smile: