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來推送它們。