【问题标题】:Facebook graph api : Param score must be an integerFacebook graph api:参数分数必须是整数
【发布时间】:2016-04-08 07:14:33
【问题描述】:

我在发布分数时使用的是 7.4 版 sdk,但出现此错误

score 发布到 fb{"error":{"message":"(#100) Param score 必须是整数","type":"OAuthException","code":100,"fbtrace_id":" ElqTb0bxXz4"}}

相关代码

var scoreData = new Dictionary<string ,string> ();
    scoreData ["score"] = UnityEngine.Random.Range (10f, 500f).ToString();
    FB.API("/me/scores?fields=",HttpMethod.POST,delegate(IGraphResult result){
    Debug.Log("score posted to the fb"+result.RawResult.ToString());


    },scoreData);

感谢任何建议或答案

【问题讨论】:

    标签: facebook-graph-api unity3d facebook-unity-sdk


    【解决方案1】:
    var scoreData = new Dictionary<string ,int> ();
        scoreData ["score"] = UnityEngine.Random.Range (10, 500);
        FB.API("/me/scores?fields=",HttpMethod.POST,delegate(IGraphResult result){
        Debug.Log("score posted to the fb"+result.RawResult.ToString());
    
    
        },scoreData);
    

    【讨论】:

    • 没试过,只是从错误信息中猜测出来的
    • argument #4' cannot convert System.Collections.Generic.Dictionary' 表达式来输入 `UnityEngine.WWWForm'
    • 哦,好吧,然后试试这个: var scoreData = new Dictionary (); scoreData ["score"] = UnityEngine.Random.Range (10, 500).ToString();
    • 唯一的区别是 Random(10f, 500f) 可能返回 395.46 这不是整数,而 Random(10, 500) 只会给你整数
    • 好吧,这似乎工作只是给了我错误需要扩展权限
    【解决方案2】:

    我遇到了同样的错误,我今天修复了它。

    问题是 我没有将整数类转换为字符串。 问题可能是您的分数保存为浮点数,当您将它们转换为 ToString 时,它们会转换为 2.00,因此,不是 Facebook 请求的 int。

    我创建了一个变量:

    int intScore = (int)myScore.
    

    然后将它添加到我的字典中。

    var dict = new Dictionary<string, string>();
    dict["score"] = myScore.ToString;
    

    完美无缺。

    【讨论】:

      猜你喜欢
      • 2017-02-03
      • 1970-01-01
      • 1970-01-01
      • 2019-01-02
      • 2017-02-24
      • 1970-01-01
      • 1970-01-01
      • 2017-06-24
      • 1970-01-01
      相关资源
      最近更新 更多