1
我正在通过Facebook
游戏教程和我的part 5 - Publish Open Graph Story.这部分重点将分数发布到用户分数饲料。我遇到的问题是它执行代码,似乎没有任何问题,但不会在Facebook上发布评分。这里是一个要发布他们的得分代码:得分不会发布到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
了权限的定义是:
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
任何帮助,建议,或建议将不胜感激!谢谢!
和日志说什么? – 2013-04-24 20:07:57
没有错误日志,但它确实打到了我放在代码中的日志,所以它发布到logcat:'postScore'和'successfully posted'。尽管在我的Facebook页面上搜索时,我发现它实际上没有发布 – chRyNaN 2013-04-24 20:29:52
尝试使用分数API对您的应用程序进行读取(GET)(https://developers.facebook.com/docs/scores/ )在图表资源管理器(https://developers.facebook.com/tools/explorer)上查看你的分数是否正确上传。此外,您的应用是否在“应用详情”设置中被归类为“游戏”? – 2013-04-24 23:06:03