V
V
Vasily Tarasevich2016-06-03 15:05:31
Classmates
Vasily Tarasevich, 2016-06-03 15:05:31

How to pass a Stats object as parameters to the new stats send method sdk.reportStats from the OK SDK for Unity3d?

At the moment I am unable to send statistics using the sdk.reportStats method so that OK can receive it without errors. Since all methods provided by the sdk for sending requests use Dictionary(string,string), the content of the Stats object has to be translated from object state to a json string. Perhaps the problem is here, but without redoing and adding new methods to the sdk, which would use, for example, Dictionary(string,object), I do not see a solution to it.
I think an example of a valid query would also help a lot in this situation, thanks.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
XLIII, 2016-06-06
@taravask

Usage example:

ArrayList innerStats = new ArrayList()
    {
      new Hashtable()
      {
        {"id", "tutorial.start"},
        {"time", 1234567890},
        {"type", "counter"},
        {"data", new ArrayList() {
            "1"
          }
        }
      }
    };

    Hashtable stats = new Hashtable()
    {
      {"time", "1234567890"},
      {"version", "1.0"},
      {"stats", innerStats}
    };
    
    var args = new Dictionary<string, string>()
    {
      { "stats", Odnoklassniki.HTTP.JSON.Encode(stats) }
    };
    OK.API("sdk.reportStats", args, r => {
      Debug.Log(r.Text);
    });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question