Facebook在Android Studio中的得分

时间:2017-03-27 16:27:59

标签: android facebook api

我想知道如何保存并在Facebook sdk(Android)中获得分数。他们用几句话解释了这一点,但我对此一无所知:S。如何通过分数询问然后处理结果?这是我的代码:

获得分数

Bundle param = new Bundle();
param.putInt("score", myScore);

accessToken = AccessToken.getCurrentAccessToken();
new GraphRequest(
        accessToken,
        "/me/scores",
        param,
        HttpMethod.POST,
        new GraphRequest.Callback() {
            public void onCompleted(GraphResponse response) {
            }
        }
).executeAsync();

设置分数

accessToken = AccessToken.getCurrentAccessToken();
new GraphRequest(
        accessToken,
        "/me/scores",
        null,
        HttpMethod.GET,
        new GraphRequest.Callback() {
            public void onCompleted(GraphResponse response) {
                try {
                    fbTotalScore = response.getJSONObject().getInt("score");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                tvTotalPushUps.setText(String.valueOf(fbTotalScore));
            }
        }
).executeAsync();

0 个答案:

没有答案