使用HttpMethod.POST unity3D发布到Facebook墙

时间:2014-11-26 11:49:50

标签: c# facebook facebook-graph-api unity3d

我正在使用团结并尝试在我的墙上张贴...我导入了Facebook sdk,我在他们的文档中使用了代码

int score = 10000;

var scoreData = 
    new Dictionary<string, string>() {{"score", score.ToString()}};

FB.API ("/me/scores", HttpMethod.POST, LogCallback, scoreData);

我允许发布设置(当我登录时)仍然没有任何反应.. 所以这是我的代码

    void Awake(){
    FB.Init (SetInit, OnHideUnity);



}

private void SetInit(){
    Debug.Log("IN");



}

private void OnHideUnity(bool isGameShown){

    if (!isGameShown) {
        Time.timeScale=0;

    }


    else {

        Time.timeScale = 1;
    }

}
    void FBlogin()
{if (!FB.IsLoggedIn) {

                    FB.Login ("email,publish_actions", AuthCallback);
            }
    else {  if (FB.IsLoggedIn) {
            //  Screen.orientation = ScreenOrientation.LandscapeRight;


            Dictionary<string,string> score1=new Dictionary<string, string>();
            score1.Add("Score","100");



            FB.API ("/me/scores",Facebook.HttpMethod.POST, AuthCallback, score1);
            Debug.Log("Okay");




        } 


            }
}


void AuthCallback(FBResult result){
    if (FB.IsLoggedIn) {
    //  Screen.orientation = ScreenOrientation.LandscapeRight;

        int score = 10000;

        Dictionary<string,string> scoreData = 
        new Dictionary<string, string>() {{"score", score.ToString()}};

        FB.API ("me/scores", HttpMethod.POST, LogCallback, scoreData);


        Dictionary<string,string> scoreData1 = 
        new Dictionary<string, string>() {{"score", "0"}};





    } 


    else {
        Debug.Log("FB LOGIN ERROR");        


    }

}

1 个答案:

答案 0 :(得分:1)

如果你想发布到Facebook

,我发现我做错了什么
    FB.API ("/me/feed", HttpMethod.POST, LogCallback,   new Dictionary<string, string>() {{"access_token", FB.AccessToken},{"message","Test"}});

而不是“test”写你的帖子..这会在没有fb对话框的情况下自动发生(你需要代表我自己发帖...)