I had a perfectly working game with retrieving and posting scores to a database with this code.
public void SendScore(string name, int score)
{
Hashtable data = new Hashtable();
data.Add("name", name);
data.Add("score", score);
HTTP.Request postRequest = new HTTP.Request("post", "https://Mygame.firebaseio.com/scores.json", data);
postRequest.Send(( request ) => {
Hashtable jsonObj = (Hashtable)JSON.JsonDecode(request.response.Text);
if(jsonObj == null)
{
Debug.LogError("server returned null or malformed response ):");
}
});
}
But since I’m making a facebook version of this game it has to be able to post with HTTPS supported so I had to switch to the WWW and WWWForm method. I’ve got my GET function working already, but I’m a bit stuck with the POST. It keeps giving me a 400: BAD REQUEST. This is what I have
public void PostScore(string name, int score)
{
WWWForm form = new WWWForm();
form.AddField("name", name);
form.AddField("score", score);
WWW www = new WWW("https://Mygame.firebaseio.com/scores.json", form);
StartCoroutine(WaitForRequest(www));
}