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 

任何帮助,建议,或建议将不胜感激!谢谢!

+0

和日志说什么? – 2013-04-24 20:07:57

+0

没有错误日志,但它确实打到了我放在代码中的日志,所以它发布到logcat:'postScore'和'successfully posted'。尽管在我的Facebook页面上搜索时,我发现它实际上没有发布 – chRyNaN 2013-04-24 20:29:52

+1

尝试使用分数API对您的应用程序进行读取(GET)(https://developers.facebook.com/docs/scores/ )在图表资源管理器(https://developers.facebook.com/tools/explorer)上查看你的分数是否正确上传。此外,您的应用是否在“应用详情”设置中被归类为“游戏”? – 2013-04-24 23:06:03

回答

0

Facebook控件作为一个故事,而不是。当你重复发布高分时,Facebook不太可能会在你的时间表上发布每一个故事。如果你想要这种行为,我建议直接将时间表发布为自定义消息,而不是依靠分数API来推送它们。