私はFacebook
ゲームのチュートリアルを進めており、パート 5 - オープン グラフ ストーリーの公開に取り組んでいます。このパートでは、ユーザーのスコア フィードにスコアを投稿することに焦点を当てます。私が抱えている問題は、一見問題なくコードを実行しているにもかかわらず、スコアを Facebook に投稿していないことです。スコアを投稿するコードは次のとおりです。
public void postScore(int score){
Log.d(TAG, "postScore");
Session session = Session.getActiveSession();
if (session == null || !session.isOpened()) {
Log.d(TAG, "SESSION == NULL OR IS NOT OPENED");
return;
}
List<String> permissions = session.getPermissions();
if (!permissions.containsAll(PERMISSIONS)) {
Log.d(TAG, "requestPublishPermissions");
requestPublishPermissions(session);
}
Bundle fbParams = new Bundle();
fbParams.putString("score", "" + score);
Request postScoreRequest = new Request(Session.getActiveSession(),
"me/scores",
fbParams,
HttpMethod.POST,
new Request.Callback() {
@Override
public void onCompleted(Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
Log.d(TAG, "error posting");
handleError(error, false);
}
Log.d(TAG, "successfully posted");
}
});
Request.executeBatchAsync(postScoreRequest);
}// end of postScore() method
PERMISSIONS は次のように定義されています。
protected static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
requestPublishPermissions() は次のように定義されます。
protected void requestPublishPermissions(Session session) {
if (session != null) {
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, PERMISSIONS)
// demonstrate how to set an audience for the publish permissions,
// if none are set, this defaults to FRIENDS
.setDefaultAudience(SessionDefaultAudience.FRIENDS)
.setRequestCode(REAUTH_ACTIVITY_CODE);
session.requestNewPublishPermissions(newPermissionsRequest);
}
}//end of requestPublishPermissions() method
ヘルプ、提案、またはアドバイスをいただければ幸いです。ありがとう!