I explain my situation, so, I’m working on a game which is suppose to send score, pseudo, etc, to a web leaderboard. My problem is that I’ve two different URL, one for login (url/Account/Login) and the second to post my form (url/api/Post).
So, my question is, is it possible to login to the first URL and then send my form to the second?
I tried some things like that but nothing worked, I’ve got errors “500 Internal Server Error” or “401 unauthorized”.
IEnumerator SendForm(){
WWWForm form = new WWWForm();
Hashtable headers = form.headers;
form.AddField ("null", "null");
byte[] data = form.data;
headers["Authorization"]="Basic " + System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("usernam:password"));
WWW w = new WWW(url+"Account/Login", data, headers);
yield return w;
if (!string.IsNullOrEmpty(w.error)) {
Debug.Log(w.error);
}
else {
Debug.Log(w.text);
form.AddField ("name", name);
form.AddField ("playerName", playerName);
form.AddField ("nationality", nationality);
form.AddField ("mobile", phone);
form.AddField ("points", GameManager.score.ToString());
WWW www = new WWW(url+"api/Scores", data, headers);
yield return www;
if (!string.IsNullOrEmpty(www.error)) {
Debug.Log(www.error);
}
else {
Debug.Log(www.text);
}
}
}